Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Deep-Dark-Forest committed Feb 2, 2025
1 parent 6ad27a3 commit c5e0ebd
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions .github/workflows/issue-close.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
name: Issue Label Handler
name: Auto Close Issues Based on Labels

on:
issues:
types: [labeled]

jobs:
handle-label:
auto-close-issue:
runs-on: ubuntu-latest
strategy:
matrix:
label-reason-pair:
- { label: "❌ 拒绝", reason: "not_planned" }
- { label: "😂 移交上游", reason: "not_planned" }
- { label: "❌ 忽略", reason: "not_planned" }
- { label: "❌ 第三方", reason: "not_planned" }
- { label: "❌ 暂无计划", reason: "not_planned" }
- { label: "👌 完成", reason: "completed" }
- { label: "❌ 重复", reason: "duplicate" }

steps:
- name: Set up environment variables
# 处理 not_planned 关闭类型
- name: Close as not planned
if: |
contains('❌ 拒绝,😂 移交上游,❌ 忽略,❌ 第三方,❌ 暂无计划', github.event.label.name)
env:
ISSUE_NUMBER: ${{ github.event.issue.number }}
REPO_OWNER: ${{ github.repository_owner }}
REPO_NAME: ${{ github.event.repository.name }}
LABEL_NAME: ${{ github.event.label.name }}
GITHUB_TOKEN: ${{ secrets.BOT }}
run: |
echo "ISSUE_NUMBER=$ISSUE_NUMBER" >> $GITHUB_ENV
echo "REPO_OWNER=$REPO_OWNER" >> $GITHUB_ENV
echo "REPO_NAME=$REPO_NAME" >> $GITHUB_ENV
echo "LABEL_NAME=$LABEL_NAME" >> $GITHUB_ENV
echo "GITHUB_TOKEN=$GITHUB_TOKEN" >> $GITHUB_ENV
gh api \
--method PATCH \
/repos/${{ github.repository }}/issues/${{ github.event.issue.number }} \
-f state=closed \
-f state_reason="not_planned"
- name: Close issue if needed
if: env.LABEL_NAME == matrix.label-reason-pair.label
# 处理 completed 关闭类型
- name: Close as completed
if: github.event.label.name == '👌 完成'
env:
GITHUB_TOKEN: ${{ secrets.BOT }}
run: |
curl -X PATCH \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/issues/$ISSUE_NUMBER \
-d "{\"state\": \"closed\"}"
gh api \
--method PATCH \
/repos/${{ github.repository }}/issues/${{ github.event.issue.number }} \
-f state=closed \
-f state_reason="completed"
# 处理 duplicate 关闭类型
- name: Close as duplicate
if: github.event.label.name == '❌ 重复'
env:
GITHUB_TOKEN: ${{ secrets.BOT }}
run: |
gh api \
--method PATCH \
/repos/${{ github.repository }}/issues/${{ github.event.issue.number }} \
-f state=closed \
-f state_reason="duplicate"

0 comments on commit c5e0ebd

Please sign in to comment.