From f437ad50c9b991ee27c950793aa3abff9e6aa276 Mon Sep 17 00:00:00 2001 From: Mengting Jiang <787982239@qq.com> Date: Mon, 10 Feb 2025 15:20:44 +0800 Subject: [PATCH] chore: sync antv shared github config (#6599) * chore: sync antv shared github config * chore: change version enum * chore: upgrade actions/upload-artifact --- .github/ISSUE_TEMPLATE/1.bug_report.yml | 84 +++++++ .github/ISSUE_TEMPLATE/2.feature_request.yml | 25 +++ .github/ISSUE_TEMPLATE/3.docs_feedback.yml | 82 +++++++ .github/ISSUE_TEMPLATE/bug_report.yml | 67 ------ .github/ISSUE_TEMPLATE/config.yml | 9 + .github/workflows/build.yml | 2 +- .github/workflows/ensure-triage-label.yml | 37 ++++ .github/workflows/manage-labeled.yml | 209 ++++++++++++++++++ .github/workflows/mark-duplicate.yml | 23 ++ .github/workflows/no-response.yml | 60 +++++ .../workflows/resolved-pending-release.yml | 27 +++ .github/workflows/sync-issue-label.yml | 123 +++++++++++ 12 files changed, 680 insertions(+), 68 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/1.bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/2.feature_request.yml create mode 100644 .github/ISSUE_TEMPLATE/3.docs_feedback.yml delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/workflows/ensure-triage-label.yml create mode 100644 .github/workflows/manage-labeled.yml create mode 100644 .github/workflows/mark-duplicate.yml create mode 100644 .github/workflows/no-response.yml create mode 100644 .github/workflows/resolved-pending-release.yml create mode 100644 .github/workflows/sync-issue-label.yml diff --git a/.github/ISSUE_TEMPLATE/1.bug_report.yml b/.github/ISSUE_TEMPLATE/1.bug_report.yml new file mode 100644 index 0000000000..83bd5d77c0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/1.bug_report.yml @@ -0,0 +1,84 @@ +name: '🐞 Bug Report' +description: Create a report to help us improve, Ask questions in Discussions / 创建一个问题报告以帮助我们改进,提问请到 Discussions +title: '[Bug]: ' +labels: ['waiting for maintainer'] +body: + - type: markdown + attributes: + value: | + Report errors and exceptions found in the project. + + Before submitting a new bug/issue, please check the links below to see if there is a solution or question posted there already: + + --- + + 反馈在项目中发现的错误、异常。 + + 在提交新 issue 之前,先通过以下链接检查是否存在相同问题: + + > [Issues](../issues) | [Closed Issues](../issues?q=is:issue+is:closed) | [Discussions](../discussions) + + - type: textarea + id: description + attributes: + label: Describe the bug / 问题描述 + placeholder: | + If there is a code block, please use Markdown syntax, such as: + 如包含代码块,请使用 Markdown 语法,如: + + ```javascript + // Your code here + ``` + validations: + required: true + - type: input + id: link + attributes: + label: Reproduction link / 复现链接 + placeholder: | + CodeSandbox / StackBlitz / ... + description: | + 可以使用 CodeSandbox(https://codesandbox.io/s/antv-g2-5-0-template-z2gsmn?file=/src/index.js) 或者 StackBlitz(https://stackblitz.com/) 重现你的问题。 + validations: + required: false + - type: textarea + id: steps + attributes: + label: Steps to Reproduce the Bug or Issue / 重现步骤 + validations: + required: false + - type: dropdown + id: version + attributes: + label: Version / 版本 + options: + - Please select / 请选择 + - 🆕 5.x + - 4.x + - 3.x + validations: + required: true + - type: checkboxes + id: OS + attributes: + label: OS / 操作系统 + options: + - label: macOS + - label: Windows + - label: Linux + - label: Others / 其他 + validations: + required: true + - type: checkboxes + id: Browser + attributes: + label: Browser / 浏览器 + options: + - label: Chrome + - label: Edge + - label: Firefox + - label: Safari (Limited support / 有限支持) + - label: IE (Nonsupport / 不支持) + - label: Others / 其他 + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/2.feature_request.yml b/.github/ISSUE_TEMPLATE/2.feature_request.yml new file mode 100644 index 0000000000..da9b530256 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/2.feature_request.yml @@ -0,0 +1,25 @@ +name: '💡 Feature Request' +description: I have a suggestion (and may want to implement it) / 我有一个建议(或者想参与贡献) +title: '[Feat]: ' +labels: ['waiting for maintainer'] +body: + - type: textarea + id: description + attributes: + label: Describe the feature / 功能描述 + description: 'What problem does this feature solve? / 这个功能解决什么问题?' + placeholder: | + I would like to see... because... + 我希望能有... 因为... + validations: + required: true + + - type: dropdown + attributes: + label: Are you willing to contribute? / 是否愿意参与贡献? + options: + - Please select / 请选择 + - ✅ Yes / 是 + - ❌ No / 否 + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/3.docs_feedback.yml b/.github/ISSUE_TEMPLATE/3.docs_feedback.yml new file mode 100644 index 0000000000..e34585a826 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/3.docs_feedback.yml @@ -0,0 +1,82 @@ +name: '📖 Docs Feedback' +description: 'Help us make our docs better! Share your thoughts and suggestions / 帮助我们改进文档!分享您的想法和建议' +labels: ['waiting for maintainer'] +title: '[docs]: ' +body: + - type: markdown + attributes: + value: | + ### 👋 Hello there! / 您好! + + Thank you for helping us improve our documentation! Your feedback is invaluable to us and will help make our docs better for everyone. + + 感谢您帮助我们改进文档!您的反馈对我们来说非常宝贵,这将帮助我们为所有人提供更好的文档体验。 + + - type: input + id: page-url + attributes: + label: '📍 Which page are you reading?' + description: "Please share the URL of the page you'd like to give feedback on / 请分享您想要反馈的页面链接" + placeholder: 'https://docs.example.com/' + validations: + required: true + + - type: dropdown + id: feedback-type + attributes: + label: "💭 What's on your mind?" + description: 'What kind of feedback would you like to share? / 您想分享什么类型的反馈?' + options: + - 'Could be clearer / 需要更清晰的解释' + - 'Missing information / 信息不完整' + - 'Example needs fixing / 示例需要修复' + - 'Content needs updating / 内容需要更新' + - 'Other suggestions / 其他建议' + validations: + required: true + + - type: textarea + id: description + attributes: + label: '🤔 Tell us more' + description: | + Let us know what went wrong when you were using this documentation and what we could do to improve it | 请告知您在使用此文档时遇到的问题以及我们可以改进的地方 + placeholder: | + Share your experience: + - What confused you? + - What were you looking for? + - What would have helped you understand better? + + 分享您的体验: + - 哪里让您感到困惑? + - 您在寻找什么信息? + - 什么样的改进能帮助您更好地理解? + validations: + required: true + + - type: textarea + id: suggestion + attributes: + label: '💡 Got any suggestions?' + description: | + What are you trying to accomplish? Providing context helps us come up with a solution that is more useful in the real world | 您希望实现什么目标?提供上下文有助于我们提出更实用的解决方案 + placeholder: | + Some ideas you might share: + - Adding more examples + - Including screenshots + - Providing step-by-step guides + + 您可以建议: + - 添加更多示例 + - 包含截图说明 + - 提供步骤指南 + validations: + required: false + + - type: markdown + attributes: + value: | + --- + 💝 Thanks for taking the time to fill out this form! Your feedback helps make our documentation better for everyone. + + 感谢您抽出宝贵时间填写这份反馈!您的建议将帮助我们为所有人提供更好的文档。 diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml deleted file mode 100644 index a078d78717..0000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: '🐞 新 Issue' -description: 创建一个新的 issue,如果你的 issue 不符合规范,它将会被自动关闭。 -body: - - type: markdown - attributes: - value: | - 在提交新 issue 之前,先通过以下链接查看有没有类似的 bug 或者建议: - - [G2 Issues](https://github.com/antvis/G2/issues) - - [G2 Discussions](https://github.com/antvis/G2/discussions) - - type: textarea - id: description - attributes: - label: 问题描述 - description: 简洁清晰地描述你遇到的问题。 - validations: - required: true - - type: input - id: link - attributes: - label: 重现链接 - description: | - 可以使用 CodeSandbox(https://codesandbox.io/s/antv-g2-5-0-template-z2gsmn?file=/src/index.js) 或者 StackBlitz(https://stackblitz.com/) 重现你的问题。 - placeholder: | - 示例: CodeSandBox 或者 StackBlitz URL - validations: - required: false - - type: textarea - id: steps - attributes: - label: 重现步骤 - description: 简洁清晰的重现步骤能够帮助我们更迅速地定位问题所在。 - placeholder: | - 1.进入页面... - 2.点击.... - 3.查看错误.... - validations: - required: false - - type: textarea - id: expected - attributes: - label: 预期行为 - description: 描述你期望的结果以及实际的结果。 - placeholder: | - 我期望看到...,但我看到了... - validations: - required: false - - type: textarea - id: platform - attributes: - label: 平台 - value: | - - 操作系统: [macOS, Windows, Linux, React Native ...] - - 网页浏览器: [Google Chrome, Safari, Firefox] - validations: - required: false - - type: textarea - id: screenshots_or_videos - attributes: - label: 屏幕截图或视频(可选) - description: 可以添加屏幕截图或视频帮助你解释问题。 - placeholder: | - 可以将你的图片或者视频拖拽到此处↓ - - type: textarea - id: additional - attributes: - label: 补充说明(可选) - description: 比如:遇到这个 bug 的业务场景、上下文。 \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000000..0452ad5714 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,9 @@ +# Ref: https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository#configuring-the-template-chooser +blank_issues_enabled: false +contact_links: + - name: 📝 Question / 问题咨询 + url: https://github.com/antvis/github-config/discussions/new?category=q-a + about: Ask the community for help / 向社区寻求帮助 + - name: 💬 Join Discussion Group / 加入讨论群 + url: https://qr.dingtalk.com/action/joingroup?code=v1,k1,rQHsK/OOTPX8ixM/DaXcL3goIYpnpKr/AFIonmA1SOM=&_dt_no_comment=1&origin=11? + about: Join DingTalk discussion group / 加入钉钉讨论群 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8c5bc31914..8682adddef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,7 +32,7 @@ jobs: - name: Upload blob report to GitHub Actions Artifacts if: always() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: snapshots path: | diff --git a/.github/workflows/ensure-triage-label.yml b/.github/workflows/ensure-triage-label.yml new file mode 100644 index 0000000000..51afbda42b --- /dev/null +++ b/.github/workflows/ensure-triage-label.yml @@ -0,0 +1,37 @@ +name: Ensure Triage Label is Present + +on: + label: + types: + - deleted + issues: + types: + - opened + +permissions: {} + +jobs: + label_issues: + runs-on: ubuntu-latest + permissions: + issues: write + steps: + - uses: actions/github-script@v7.0.1 + with: + script: | + const labelToTriage = 'waiting for maintainer'; + + const { data: labels } = await github.rest.issues.listLabelsOnIssue({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + }); + + if (labels.length <= 0) { + await github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: [labelToTriage] + }) + } diff --git a/.github/workflows/manage-labeled.yml b/.github/workflows/manage-labeled.yml new file mode 100644 index 0000000000..a98e3c04e8 --- /dev/null +++ b/.github/workflows/manage-labeled.yml @@ -0,0 +1,209 @@ +name: Manage Labeled Issue + +on: + issues: + types: [labeled] + +permissions: {} + +jobs: + manage-labels: + runs-on: ubuntu-latest + permissions: + issues: write + steps: + # 当添加分类标签时,移除 'waiting for maintainer' 标签 + - name: Remove `waiting for maintainer` label when other triage labels are added + uses: actions/github-script@v7.0.1 + with: + script: | + const labelsToCheck = ['waiting for author', 'need improvement', 'bug 🐛', 'documentation 📖', 'feature 💡', 'question 💬', 'notabug', 'stale', 'wontfix', 'duplicate']; + + const labelToRemove = 'waiting for maintainer'; + const newLabel = context.payload.label.name; + + if (labelsToCheck.includes(newLabel)) { + const { data: labels } = await github.rest.issues.listLabelsOnIssue({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + }); + if (labels.some(label => label.name === labelToRemove)) { + await github.rest.issues.removeLabel({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + name: labelToRemove, + }); + } + } + + # 当添加 'need improvement' 标签时,同时添加 'waiting for author' 标签 + - name: Append label if `need improvement` is added + if: github.event.label.name == 'need improvement' + uses: actions-cool/issues-helper@v3.6.0 + with: + actions: "add-labels" + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} + labels: "waiting for author" + + # 当添加 'need improvement' 标签时,发送提醒评论 + - name: Warn bad issue when `need improvement` label is added + if: github.event.label.name == 'need improvement' + uses: actions-cool/issues-helper@v3 + with: + actions: "create-comment" + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} + body: | + 📝 To help us better understand and address your issue, **please provide more information, or use the standard format**, otherwise we will not process this issue. + + Reference document: + + - [Creating an issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/creating-an-issue) + - [Basic writing and formatting syntax](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax) + + --- + + 📝 为了帮助我们更好地理解和解决你的问题,**请提供更多信息,或者使用规范的格式**,否则我们不会处理这个 issue。 + + 参考文档: + + - [创建议题](https://docs.github.com/zh/issues/tracking-your-work-with-issues/using-issues/creating-an-issue) + - [基本撰写和格式语法](https://docs.github.com/zh/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax) + emoji: "heart" + + # 处理 stale 标签 + - name: Add stale issue comment before closing + if: github.event.label.name == 'stale' + uses: actions-cool/issues-helper@v3 + with: + actions: "create-comment" + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} + body: | + ⚠️ This issue has been automatically closed due to inactivity. + + - If the issue is still relevant and important to you, feel free to: + 1. Reopen with additional information + 2. Create a new issue with updated context + 3. Reference any related issues or discussions + + We close inactive issues to keep our backlog manageable and focused on active issues. + + Your contribution makes our project better! 🌟 + + --- + + ⚠️ 由于长期无活动,此 issue 已被自动关闭。 + + - 如果这个问题对您来说仍然重要,您可以: + 1. 重新打开并提供补充信息 + 2. 创建一个新的 issue 并更新相关背景 + 3. 关联相关的 issue 或讨论 + + 为了更好地维护项目,我们需要定期清理不活跃的问题。 + + 感谢您为开源添砖加瓦!🌟 + emoji: "heart" + + - name: Close stale issue + if: github.event.label.name == 'stale' + uses: actions-cool/issues-helper@v3 + with: + actions: "close-issue" + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} + + # 处理 wontfix 标签 + - name: Add wontfix issue comment before closing + if: github.event.label.name == 'wontfix' + uses: actions-cool/issues-helper@v3 + with: + actions: "create-comment" + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} + body: | + 🚫 This issue has been marked as "Won't Fix". Here's why: + + - The described behavior is working as intended + - The request falls outside our project scope/goals + - The cost/benefit ratio doesn't justify the change + + If you have new information that might change this decision, feel free to: + 1. Share your additional context + 2. Propose alternative solutions + 3. Start a discussion to explore different approaches + + Thank you for your understanding and engagement! 🙏 + + --- + + 🚫 此 issue 被标记为"不予修复",原因如下: + + - 当前行为符合设计预期 + - 该请求超出项目范围/目标 + - 投入产出比不足以支持此变更 + + 如果您有任何新的想法或建议,欢迎: + 1. 分享更多上下文 + 2. 提出替代方案 + 3. 发起讨论以探索不同思路 + + 感谢理解与支持!🙏 + emoji: "heart" + + - name: Close wontfix issue + if: github.event.label.name == 'wontfix' + uses: actions-cool/issues-helper@v3 + with: + actions: "close-issue" + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} + + # 处理 notabug 标签 + - name: Add notabug issue comment before closing + if: github.event.label.name == 'notabug' + uses: actions-cool/issues-helper@v3 + with: + actions: "create-comment" + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} + body: | + ✅ After careful review, we've determined this is not a bug. Here's why: + + - The current behavior is working as designed + - This might be a misunderstanding of the feature + - The issue cannot be reproduced with the provided information + + If you still believe this is a bug, please: + 1. Provide a minimal reproduction + 2. Share your expected behavior + 3. Include more detailed environment information + + Thank you for helping us improve our project! 💫 + + --- + + ✅ 经过仔细核查,这并非一个 bug,原因如下: + + - 当前表现符合设计预期 + - 可能是对功能理解有所偏差 + - 基于已提供信息无法复现问题 + + 如果您仍认为这是一个 bug,建议: + 1. 提供最小复现示例 + 2. 说明您期望的表现 + 3. 补充更详细的环境信息 + + 期待您的反馈!💫 + emoji: "heart" + + - name: Close notabug issue + if: github.event.label.name == 'notabug' + uses: actions-cool/issues-helper@v3 + with: + actions: "close-issue" + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} diff --git a/.github/workflows/mark-duplicate.yml b/.github/workflows/mark-duplicate.yml new file mode 100644 index 0000000000..c142a5f39c --- /dev/null +++ b/.github/workflows/mark-duplicate.yml @@ -0,0 +1,23 @@ +name: Mark Duplicate Issue + +on: + issue_comment: + types: [created, edited] + +permissions: {} + +jobs: + mark-duplicate: + runs-on: ubuntu-latest + permissions: + contents: read + issues: write + steps: + - name: Mark duplicate issue + uses: actions-cool/issues-helper@v3.6.0 + with: + actions: "mark-duplicate" + token: ${{ secrets.GITHUB_TOKEN }} + duplicate-labels: "duplicate" + remove-labels: "waiting for maintainer" + close-issue: true diff --git a/.github/workflows/no-response.yml b/.github/workflows/no-response.yml new file mode 100644 index 0000000000..82f1844509 --- /dev/null +++ b/.github/workflows/no-response.yml @@ -0,0 +1,60 @@ +name: No Response + +# `issues`.`closed`, `issue_comment`.`created`, and `scheduled` event types are required for this Action +# to work properly. +on: + issues: + types: + - closed + issue_comment: + types: + - created + schedule: + # These runs in our repos are spread evenly throughout the day to avoid hitting rate limits. + # If you change this schedule, consider changing the remaining repositories as well. + # Runs at 12 am, 12 pm + - cron: "0 0,12 * * *" + +permissions: {} + +jobs: + noResponse: + runs-on: ubuntu-latest + permissions: + contents: read + issues: write + steps: + - uses: MBilalShafi/no-response-add-label@v0.0.6 + with: + token: ${{ secrets.GITHUB_TOKEN }} + # Number of days of inactivity before an Issue is closed for lack of response + daysUntilClose: 7 + # Label requiring a response + responseRequiredLabel: "waiting for author" + # Label to add back when required label is removed + optionalFollowupLabel: "waiting for maintainer" + # Comment to post when closing an Issue for lack of response. Set to `false` to disable + closeComment: | + ⚠️ This issue has been automatically closed due to inactivity. + + - If the issue is still relevant and important to you, feel free to: + 1. Reopen with additional information + 2. Create a new issue with updated context + 3. Reference any related issues or discussions + + We close inactive issues to keep our backlog manageable and focused on active issues. + + Your contribution makes our project better! 🌟 + + --- + + ⚠️ 由于长期无活动,此 issue 已被自动关闭。 + + - 如果这个问题对您来说仍然重要,您可以: + 1. 重新打开并提供补充信息 + 2. 创建一个新的 issue 并更新相关背景 + 3. 关联相关的 issue 或讨论 + + 为了更好地维护项目,我们需要定期清理不活跃的问题。 + + 感谢您为开源添砖加瓦!🌟 diff --git a/.github/workflows/resolved-pending-release.yml b/.github/workflows/resolved-pending-release.yml new file mode 100644 index 0000000000..898be1416f --- /dev/null +++ b/.github/workflows/resolved-pending-release.yml @@ -0,0 +1,27 @@ +name: Resolved Pending Release + +on: + release: + types: [published] + +permissions: {} + +jobs: + comment-on-issues: + runs-on: ubuntu-latest + permissions: + issues: write + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + # Check this repository out, otherwise the script won't be available, + # as it otherwise checks out the repository where the workflow caller is located + repository: antvis/github-config + + - name: Comment on issues + uses: actions/github-script@v7.0.1 + with: + script: | + const script = require('./.github/workflows/scripts/closeOnRelease.js'); + await script({core, github, context}); diff --git a/.github/workflows/sync-issue-label.yml b/.github/workflows/sync-issue-label.yml new file mode 100644 index 0000000000..22878d940a --- /dev/null +++ b/.github/workflows/sync-issue-label.yml @@ -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); + } + }