-
Notifications
You must be signed in to change notification settings - Fork 1
76 lines (69 loc) · 2.54 KB
/
auto-tag.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Auto Tag
on:
issues:
types:
- reopened
- closed
pull_request:
types:
- closed
env:
PRE_LABEL_NAME: un-released
jobs:
setup-labels:
if: ${{ !github.event.release }}
runs-on: ubuntu-latest
env:
REPO: ${{ github.event.repository.full_name }}
steps:
- name: Get `${{ env.PRE_LABEL_NAME }}` label
id: label-list
run: echo label=$(gh label list --search $PRE_LABEL_NAME -L 1 --json name -q '.[].name' --repo $REPO) >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Create label if does not exist
if: ${{ steps.label-list.outputs.label != env.PRE_LABEL_NAME }}
run: |
gh label create $PRE_LABEL_NAME --color e3fce3 --repo $REPO;
echo ':neckbeard: Created the `${{ env.PRE_LABEL_NAME }}` label !' >> $GITHUB_STEP_SUMMARY;
env:
GITHUB_TOKEN: ${{ github.token }}
tag-closed-issues:
runs-on: ubuntu-latest
if: ${{ github.event.issue.state_reason == 'completed' }}
env:
REPO: ${{ github.event.repository.full_name }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
steps:
- name: Tag Issue
run: |
gh issue edit $ISSUE_NUMBER --add-label $PRE_LABEL_NAME --repo $REPO;
echo ':label: Issue ${{ github.event.issue.html_url }} has been tagged as `${{ env.PRE_LABEL_NAME }}`' >> $GITHUB_STEP_SUMMARY;
env:
GITHUB_TOKEN: ${{ github.token }}
untag-reopened-issues:
runs-on: ubuntu-latest
if: ${{ github.event.issue.state_reason == 'reopened' }}
env:
REPO: ${{ github.event.repository.full_name }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
steps:
- name: Untag Issue
run: |
gh issue edit $ISSUE_NUMBER --remove-label $PRE_LABEL_NAME --repo $REPO;
echo ':recycle: Issue ${{ github.event.issue.html_url }} has been untagged of `${{ env.PRE_LABEL_NAME }}`' >> $GITHUB_STEP_SUMMARY;
env:
GITHUB_TOKEN: ${{ github.token }}
tag-merged-prs:
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.merged }}
env:
REPO: ${{ github.event.repository.full_name }}
PR_NUMBER: ${{ github.event.pull_request.number }}
steps:
- name: Tag PR
run: |
gh pr edit $PR_NUMBER --add-label $PRE_LABEL_NAME --repo $REPO;
echo ':label: PR ${{ github.event.pull_request.html_url }} was merged and has been tagged as `${{ env.PRE_LABEL_NAME }}`' >> $GITHUB_STEP_SUMMARY;
env:
GITHUB_TOKEN: ${{ github.token }}