chore: remove one-time script; fix issue template labels

[skip ci] [skip netlify]
This commit is contained in:
Typed SIGTERM
2025-08-28 10:32:00 +08:00
parent 7c5db14497
commit 0aa575381a
6 changed files with 21 additions and 282 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
name: 🐞 Bug report
description: Report an issue (Something not working? Something went wrong? Report it here!)
type: Bug
labels: [pending-triage]
labels: [pending triage]
body:
- type: markdown
attributes:
+1 -1
View File
@@ -1,7 +1,7 @@
name: 🚀 New feature proposal
description: Propose a new feature (Something you would like to see in this project?)
type: Feature
labels: [pending-triage]
labels: [pending triage]
body:
- type: markdown
attributes:
-61
View File
@@ -1,61 +0,0 @@
/* eslint-disable no-console */
import process from 'node:process'
import { Octokit } from '@octokit/rest'
const IssueTypeMapping = {
enhancement: 'Feature',
bug: 'Bug',
}
const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms))
async function migrate(octokit: Octokit, owner: string, repo: string): Promise<void> {
const allIssues = await octokit.paginate(octokit.rest.issues.listForRepo, {
owner,
repo,
state: 'all',
per_page: 100,
})
const issues = allIssues.filter(x => !x.pull_request)
for (const issue of issues) {
const labels: string[] = []
for (const label of issue.labels) {
if (typeof label === 'string')
labels.push(label)
else if (label.name)
labels.push(label.name)
}
const typeLabel = labels.find(label => label in IssueTypeMapping)
if (typeLabel) {
try {
const updatedLabels = labels.filter(x => x !== typeLabel)
await octokit.rest.issues.update({
owner,
repo,
issue_number: issue.number,
labels: updatedLabels,
type: IssueTypeMapping[typeLabel as keyof typeof IssueTypeMapping],
})
console.log(`Updated #${issue.number}`)
await sleep(100)
}
catch (error) {
console.error('Failed to update issue #%d: %o', issue.number, error)
}
}
}
}
(async () => {
const token = process.env.GITHUB_TOKEN
const repository = process.env.GITHUB_REPOSITORY
const [owner, repo] = repository?.split('/') || []
if (!token || !owner || !repo)
throw new Error('Invalid parameters')
await migrate(new Octokit({ auth: token }), owner, repo)
})()
-31
View File
@@ -1,31 +0,0 @@
name: Migrate Issue Types
on:
workflow_dispatch:
jobs:
migrate-issue-types:
runs-on: ubuntu-latest
permissions:
issues: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
- uses: pnpm/action-setup@v3
- name: Install dependencies
run: pnpm i --frozen-lockfile --ignore-scripts
- name: Run issue type migration
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
run: pnpm tsx .github/workflows/migrate-issue-types.ts