Skip to content

Commit 12e9d51

Browse files
EMaherCopilot
andcommitted
refactor: move label migration to its own daily workflow
Extracts migration logic into issue-labels-migrate.yml (runs daily at 07:00 UTC). Removes migration from issue-labels-sync.yml. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 2c3d700 commit 12e9d51

2 files changed

Lines changed: 52 additions & 33 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Migrate Legacy Labels
2+
3+
on:
4+
schedule:
5+
- cron: '0 7 * * *' # Daily at 07:00 UTC (runs before label sync at 08:00)
6+
workflow_dispatch:
7+
8+
permissions:
9+
issues: write
10+
11+
jobs:
12+
migrate:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Rename legacy labels to type: equivalents
16+
uses: actions/github-script@v7
17+
with:
18+
script: |
19+
// Legacy label → canonical type: label.
20+
// Rename preserves all issue associations automatically.
21+
const MIGRATIONS = [
22+
{ from: 'bug', to: 'type:bug' },
23+
{ from: 'question', to: 'type:question' },
24+
{ from: 'enhancement', to: 'type:enhancement' },
25+
{ from: 'documentation', to: 'type:documentation' }
26+
];
27+
28+
for (const { from, to } of MIGRATIONS) {
29+
try {
30+
await github.rest.issues.getLabel({
31+
owner: context.repo.owner,
32+
repo: context.repo.repo,
33+
name: from
34+
});
35+
// Old label exists — rename it
36+
await github.rest.issues.updateLabel({
37+
owner: context.repo.owner,
38+
repo: context.repo.repo,
39+
name: from,
40+
new_name: to
41+
});
42+
core.info(`Migrated label: ${from} → ${to}`);
43+
} catch (err) {
44+
if (err.status === 404) {
45+
core.info(`Legacy label "${from}" not found — no migration needed`);
46+
} else {
47+
core.warning(`Failed to migrate ${from}: ${err.message}`);
48+
}
49+
}
50+
}
51+
52+
core.info('Label migration complete');

.github/workflows/issue-labels-sync.yml

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -196,36 +196,3 @@ jobs:
196196
}
197197
198198
core.info(`Label sync complete: ${labels.length} labels synced`);
199-
200-
// Migrate legacy labels → type: equivalents AFTER sync ensures targets exist.
201-
// Rename preserves issue associations.
202-
const MIGRATIONS = [
203-
{ from: 'bug', to: 'type:bug' },
204-
{ from: 'question', to: 'type:question' },
205-
{ from: 'enhancement', to: 'type:enhancement' },
206-
{ from: 'documentation', to: 'type:documentation' }
207-
];
208-
209-
for (const { from, to } of MIGRATIONS) {
210-
try {
211-
await github.rest.issues.getLabel({
212-
owner: context.repo.owner,
213-
repo: context.repo.repo,
214-
name: from
215-
});
216-
// Old label exists — rename it (this moves all issues to the new name)
217-
await github.rest.issues.updateLabel({
218-
owner: context.repo.owner,
219-
repo: context.repo.repo,
220-
name: from,
221-
new_name: to
222-
});
223-
core.info(`Migrated label: ${from} → ${to}`);
224-
} catch (err) {
225-
if (err.status === 404) {
226-
core.info(`Legacy label "${from}" not found — no migration needed`);
227-
} else {
228-
core.warning(`Failed to migrate ${from}: ${err.message}`);
229-
}
230-
}
231-
}

0 commit comments

Comments
 (0)