forked from PCL-Community/PCL2-CE
-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (39 loc) · 1.56 KB
/
issue-close.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
name: Issue Label Handler
on:
issues:
types: [labeled]
jobs:
handle-label:
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
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
- name: Close issue if needed
if: env.LABEL_NAME == matrix.label-reason-pair.label
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\"}"