Skip to content

Commit

Permalink
Merge pull request #21 from antvis/sync-issue
Browse files Browse the repository at this point in the history
feat: use workflow to sync issue labels
  • Loading branch information
yvonneyx authored Feb 8, 2025
2 parents 46febe7 + 1b1617c commit a23fa38
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 0 deletions.
123 changes: 123 additions & 0 deletions .github/workflows/sync-issue-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Sync Issue Labels

on:
# 手动触发
workflow_dispatch:

jobs:
sync-labels:
runs-on: ubuntu-latest
steps:
- name: Create default labels
uses: actions/github-script@v7
with:
script: |
const labels = [
{
name: 'waiting for maintainer',
description: 'Triage or intervention needed from a maintainer',
color: 'bcf5db'
},
{
name: 'waiting for author',
description: 'Further information is requested from the author',
color: 'fef2c0'
},
{
name: 'need improvement',
description: 'Lack of information or incorrect format',
color: 'fbca04'
},
{
name: 'bug 🐛',
description: "Something isn't working",
color: 'ee0701'
},
{
name: 'documentation 📖',
description: 'Improvements or additions to documentation',
color: 'd4c5f9'
},
{
name: 'feature 💡',
description: 'A new feature request or an enhancement proposal',
color: 'a2eeef'
},
{
name: 'question 💬',
description: 'This issue is just a question. It will be converted into discussion automatically',
color: 'cc317c'
},
{
name: 'duplicate',
description: 'This issue or PR already exists and may be closed with a reference to the original',
color: 'eeeeee'
},
{
name: 'good first issue',
description: 'Good for newcomers',
color: '7057ff'
},
{
name: 'help wanted',
description: "Anyone can help, whether you're a seasoned developer or new to the project",
color: '008672'
},
{
name: 'resolved',
description: 'This issue has been resolved and is now available in the latest release',
color: '0E8A16'
},
{
name: 'resolved pending release',
description: 'This issue has been resolved and is pending release',
color: '0E8A16'
},
{
name: 'stale',
description: 'This issue has not had recent activity or appears to be solved. It will be automatically closed',
color: 'eeeeee'
},
{
name: 'wontfix',
description: 'This issue will not be fixed or otherwise handled. It will be automatically closed',
color: 'eeeeee'
},
{
name: 'notabug',
description: 'This issue reported is not a bug (e.g., misreported, not reproducible) and will be automatically closed',
color: 'eeeeee'
}
];
for (const label of labels) {
try {
// 先检查标签是否存在
try {
await github.rest.issues.getLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: label.name
});
console.log(`跳过已存在的标签: ${label.name}`);
continue; // 如果标签存在,跳过创建
} catch (error) {
if (error.status !== 404) {
throw error; // 如果不是 404 错误,抛出异常
}
// 标签不存在,继续创建
}
// 创建新标签
await github.rest.issues.createLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: label.name,
color: label.color,
description: label.description
});
console.log(`成功创建标签: ${label.name}`);
} catch (error) {
console.error(`处理标签 ${label.name} 时出错:`, error);
}
}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ When a release is published, the workflow will automatically:
- Add a comment to the issue with a message about the release
- Close the issue as completed

### `sync-issue-label.yml`

This workflow syncs the issue labels from the `antvis/github-config` repository to the current repository.

**Important: Manually Trigger the workflow**

## Issue templates

| Template | Description |
Expand Down

0 comments on commit a23fa38

Please sign in to comment.