@@ -161,38 +161,6 @@ jobs:
161161 labels.push(...SIGNAL_LABELS);
162162 labels.push(...LIFECYCLE_LABELS);
163163
164- // Migrate legacy labels → type: equivalents (rename preserves issue associations)
165- const MIGRATIONS = [
166- { from: 'bug', to: 'type:bug' },
167- { from: 'question', to: 'type:question' },
168- { from: 'enhancement', to: 'type:enhancement' },
169- { from: 'documentation', to: 'type:documentation' }
170- ];
171-
172- for (const { from, to } of MIGRATIONS) {
173- try {
174- await github.rest.issues.getLabel({
175- owner: context.repo.owner,
176- repo: context.repo.repo,
177- name: from
178- });
179- // Old label exists — rename it (this moves all issues to the new name)
180- await github.rest.issues.updateLabel({
181- owner: context.repo.owner,
182- repo: context.repo.repo,
183- name: from,
184- new_name: to
185- });
186- core.info(`Migrated label: ${from} → ${to}`);
187- } catch (err) {
188- if (err.status === 404) {
189- core.info(`Legacy label "${from}" not found — no migration needed`);
190- } else {
191- core.warning(`Failed to migrate ${from}: ${err.message}`);
192- }
193- }
194- }
195-
196164 // Sync labels (create or update)
197165 for (const label of labels) {
198166 try {
@@ -228,3 +196,36 @@ jobs:
228196 }
229197
230198 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