diff --git a/.github/workflows/issue-help-wanted.temp.yml b/.github/workflows/issue-help-wanted.temp.yml index 35a51f295..ff510183e 100644 --- a/.github/workflows/issue-help-wanted.temp.yml +++ b/.github/workflows/issue-help-wanted.temp.yml @@ -10,13 +10,19 @@ jobs: if: github.event.label.name == 'help wanted' steps: - name: Add comment - uses: actions-cool/issues-helper@v3 + uses: actions/github-script@v7 with: - actions: 'create-comment' - token: ${{ secrets.GITHUB_TOKEN }} - issue-number: ${{ github.event.issue.number }} - body: | - 任何人都可以处理此问题。 - **请务必在您的 `pull request` 中引用此问题。** :sparkles: - 感谢你的贡献! :sparkles: - emoji: 'heart' + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { data: comment } = await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: '任何人都可以处理此问题。\n**请务必在您的 `pull request` 中引用此问题。** :sparkles:\n感谢你的贡献! :sparkles:' + }); + await github.rest.reactions.createForIssueComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: comment.id, + content: 'heart' + }); diff --git a/.github/workflows/issue-label.yml b/.github/workflows/issue-label.yml index ec009a0c0..ea004895a 100644 --- a/.github/workflows/issue-label.yml +++ b/.github/workflows/issue-label.yml @@ -8,7 +8,7 @@ jobs: if: contains(fromJSON('["easy", "middle", "hard"]'), github.event.label.name) steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Get token id: token run: | @@ -41,10 +41,22 @@ jobs: duration: ${{ steps.token.outputs.duration }} deadline: ${{ steps.token.outputs.deadline }} - name: Update issue - uses: actions-cool/issues-helper@v3 + uses: actions/github-script@v7 + env: + APPEND_CONTENT: ${{ steps.template.outputs.result }} with: - actions: 'update-issue' - token: ${{ secrets.GITHUB_TOKEN }} - issue-number: ${{ github.event.issue.number }} - body: ${{ steps.template.outputs.result }} - update-mode: 'append' \ No newline at end of file + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const issue = await github.rest.issues.get({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number + }); + const currentBody = issue.data.body || ''; + const appendContent = process.env.APPEND_CONTENT; + await github.rest.issues.update({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: currentBody + '\n' + appendContent + }); \ No newline at end of file diff --git a/.github/workflows/issue-mark-duplicate.temp.yml b/.github/workflows/issue-mark-duplicate.temp.yml index a0f408354..a92401821 100644 --- a/.github/workflows/issue-mark-duplicate.temp.yml +++ b/.github/workflows/issue-mark-duplicate.temp.yml @@ -11,9 +11,33 @@ jobs: runs-on: ubuntu-latest steps: - name: mark-duplicate - uses: actions-cool/issues-helper@v3 + uses: actions/github-script@v7 with: - actions: "mark-duplicate" - token: ${{ secrets.GITHUB_TOKEN }} - duplicate-labels: "duplicate" - close-issue: true + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const body = context.payload.comment.body || ''; + const match = body.match(/[Dd]uplicate\s+of\s+#(\d+)/); + if (!match) return; + + // Only allow collaborators to mark duplicates + const authorAssociation = context.payload.comment.author_association; + const allowedRoles = ['COLLABORATOR', 'MEMBER', 'OWNER']; + if (!allowedRoles.includes(authorAssociation)) { + core.info(`Skipping: commenter role "${authorAssociation}" is not allowed to mark duplicates.`); + return; + } + + // Add 'duplicate' label + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + labels: ['duplicate'] + }); + // Close the issue + await github.rest.issues.update({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + state: 'closed' + }); diff --git a/.github/workflows/issue-reply.temp.yml b/.github/workflows/issue-reply.temp.yml index b6f13edcb..7a9a2641a 100644 --- a/.github/workflows/issue-reply.temp.yml +++ b/.github/workflows/issue-reply.temp.yml @@ -13,9 +13,13 @@ jobs: steps: - name: Need Reproduce if: github.event.label.name == 'Need Reproduce' - uses: actions-cool/issues-helper@v3 + uses: actions/github-script@v7 with: - actions: 'create-comment' - issue-number: ${{ github.event.issue.number }} - body: | - 你好 @${{ github.event.issue.user.login }}, 我们需要你提供一个在线的重现实例以便于我们帮你排查问题。你可以通过点击 [此处](https://codesandbox.io/) 创建一个 codesandbox 或者提供一个最小化的 GitHub 仓库。请确保选择准确的版本。 + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: `你好 @${{ github.event.issue.user.login }}, 我们需要你提供一个在线的重现实例以便于我们帮你排查问题。你可以通过点击 [此处](https://codesandbox.io/) 创建一个 codesandbox 或者提供一个最小化的 GitHub 仓库。请确保选择准确的版本。` + });