forked from ilysenko/codex-desktop-linux
-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (134 loc) · 5.29 KB
/
Copy pathcomputer-use-sync-reminder.yml
File metadata and controls
140 lines (134 loc) · 5.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: computer-use sync reminder
# When a merge to main touches the vendored Linux Computer Use crate, open (or
# update) an issue so the change can be propagated to the standalone
# agent-sh/computer-use-linux repo. Version-number parity between the two crates
# is the coordination signal; this makes the reminder explicit so the numbers do
# not silently drift apart.
on:
push:
branches: [main]
paths:
- 'computer-use-linux/**'
permissions:
contents: read
issues: write
concurrency:
group: computer-use-sync-reminder
cancel-in-progress: false
jobs:
remind:
name: open sync reminder
runs-on: ubuntu-latest
steps:
- name: Check out the label policy
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Open or update the sync reminder
uses: actions/github-script@d746ffe35508b1917358783b479e04febd2b8f71 # v9.0.0
with:
script: |
const policy = require(
`${process.env.GITHUB_WORKSPACE}/.github/labels.json`,
);
const labelDefinition = policy.labels.find(
({ name }) => name === 'sync: computer use',
);
if (!labelDefinition) {
throw new Error(
'Missing sync: computer use in .github/labels.json',
);
}
const label = labelDefinition.name;
const issueLabelNames = [
'type: maintenance',
'area: computer use',
'status: ready for work',
label,
];
const issueLabelDefinitions = issueLabelNames.map((name) => {
const definition = policy.labels.find((candidate) => candidate.name === name);
if (!definition) throw new Error(`Missing ${name} in .github/labels.json`);
return definition;
});
const legacyLabels = policy.migrations
.filter(({ to }) => to === label)
.map(({ from }) => from);
const hasLabel = (issue, name) => (issue.labels || []).some(
(entry) => typeof entry === 'string' ? entry === name : entry.name === name,
);
const otherRepo = 'agent-sh/computer-use-linux';
const compare = context.payload.compare || '';
const sha = context.sha.slice(0, 8);
const body = [
'A merge to `main` touched `computer-use-linux/**` (the vendored Linux Computer Use crate).',
'',
`Propagate the change to **${otherRepo}** if it is not codex-specific glue.`,
'Keep the upstream generic naming there — do **not** push `codex-*` /',
'`CODEX_COMPUTER_USE_*` names, `identity.rs`, or the chrome-extension host upstream.',
'',
`- Compare: ${compare || sha}`,
`- Triggering commit: ${context.sha}`,
'',
'Once synced, bump both crates to the same enumeration. A version mismatch',
'between this crate and the standalone one means a sync is still pending.',
].join('\n');
for (const definition of issueLabelDefinitions) {
try {
await github.rest.issues.getLabel({
...context.repo,
name: definition.name,
});
} catch (error) {
if (error.status !== 404) throw error;
await github.rest.issues.createLabel({
...context.repo,
name: definition.name,
color: definition.color,
description: definition.description,
});
}
}
let existing = await github.rest.issues.listForRepo({
...context.repo,
state: 'open',
labels: label,
per_page: 1,
});
for (const legacyLabel of legacyLabels) {
if (existing.data.length > 0) break;
const legacy = await github.rest.issues.listForRepo({
...context.repo,
state: 'open',
labels: legacyLabel,
per_page: 1,
});
if (legacy.data.length > 0) {
existing = legacy;
}
}
if (existing.data.length > 0) {
if (hasLabel(existing.data[0], 'workflow: manual only')) {
core.notice(
`Sync reminder #${existing.data[0].number} is manual-only; no item mutation was performed.`,
);
return;
}
await github.rest.issues.addLabels({
...context.repo,
issue_number: existing.data[0].number,
labels: issueLabelNames,
});
await github.rest.issues.createComment({
...context.repo,
issue_number: existing.data[0].number,
body,
});
} else {
await github.rest.issues.create({
...context.repo,
title: 'Sync Linux Computer Use → agent-sh/computer-use-linux',
labels: issueLabelNames,
body,
});
}