From 10b05851994abb2113b6256e48f85211c4f08d21 Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 11 Jun 2026 14:13:20 +0800 Subject: [PATCH] perf: update issue workflow --- .github/workflows/issue-close-require.yml | 34 ++++++++++++++++------- .github/workflows/issue-close.yml | 15 ++++++---- .github/workflows/issue-open.yml | 14 ++++++---- 3 files changed, 43 insertions(+), 20 deletions(-) diff --git a/.github/workflows/issue-close-require.yml b/.github/workflows/issue-close-require.yml index df341f211..322785621 100644 --- a/.github/workflows/issue-close-require.yml +++ b/.github/workflows/issue-close-require.yml @@ -4,17 +4,31 @@ on: schedule: - cron: "0 0 * * *" +permissions: + issues: write + jobs: issue-close-require: runs-on: ubuntu-latest steps: - - name: need reproduce - uses: actions-cool/issues-helper@v2 - with: - actions: 'close-issues' - labels: '⏳ Pending feedback' - inactive-day: 30 - body: | - You haven't provided feedback for over 30 days. - We will close this issue. If you have any further needs, you can reopen it or submit a new issue. - 您超过 30 天未反馈信息,我们将关闭该 issue,如有需求您可以重新打开或者提交新的 issue。 + - name: Close inactive issues pending feedback + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + run: | + set -euo pipefail + + cutoff="$(date -u -d '30 days ago' '+%Y-%m-%d')" + query="repo:${GH_REPO} is:issue is:open label:\"⏳ Pending feedback\" updated:<${cutoff}" + + printf '%s\n' \ + "You haven't provided feedback for over 30 days." \ + "We will close this issue. If you have any further needs, you can reopen it or submit a new issue." \ + "您超过 30 天未反馈信息,我们将关闭该 issue,如有需求您可以重新打开或者提交新的 issue。" \ + > "${RUNNER_TEMP}/close-comment.md" + + gh api --method GET --paginate /search/issues -f q="${query}" -f per_page=100 --jq '.items[].number' | + while read -r issue_number; do + gh issue comment "${issue_number}" --repo "${GH_REPO}" --body-file "${RUNNER_TEMP}/close-comment.md" + gh issue close "${issue_number}" --repo "${GH_REPO}" + done diff --git a/.github/workflows/issue-close.yml b/.github/workflows/issue-close.yml index 1ff51f456..a7a2b4a38 100644 --- a/.github/workflows/issue-close.yml +++ b/.github/workflows/issue-close.yml @@ -4,13 +4,18 @@ on: issues: types: [closed] +permissions: + issues: write + jobs: issue-close-remove-labels: runs-on: ubuntu-latest + if: ${{ !github.event.issue.pull_request }} steps: - name: Remove labels - uses: actions-cool/issues-helper@v2 - if: ${{ !github.event.issue.pull_request }} - with: - actions: 'remove-labels' - labels: '🔔 Pending processing,⏳ Pending feedback' \ No newline at end of file + run: | + gh issue edit "${{ github.event.issue.number }}" \ + --remove-label "🔔 Pending processing" \ + --remove-label "⏳ Pending feedback" + env: + GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/issue-open.yml b/.github/workflows/issue-open.yml index b1555e113..550a27d73 100644 --- a/.github/workflows/issue-open.yml +++ b/.github/workflows/issue-open.yml @@ -4,13 +4,17 @@ on: issues: types: [opened] +permissions: + issues: write + jobs: issue-open-add-labels: runs-on: ubuntu-latest + if: ${{ !github.event.issue.pull_request }} steps: - name: Add labels - uses: actions-cool/issues-helper@v2 - if: ${{ !github.event.issue.pull_request }} - with: - actions: 'add-labels' - labels: '🔔 Pending processing' \ No newline at end of file + run: | + gh issue edit "${{ github.event.issue.number }}" \ + --add-label "🔔 Pending processing" + env: + GH_TOKEN: ${{ github.token }}