-
Notifications
You must be signed in to change notification settings - Fork 481
54 lines (52 loc) · 1.68 KB
/
label-wip.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
name: Auto Label WIP
on:
pull_request_target:
types:
- opened
- reopened
- edited
- closed
jobs:
check-linked-issues:
if: github.repository == 'coronasafe/care_fe'
name: Check linked issues
runs-on: ubuntu-latest
outputs:
linked_issues: ${{ steps.issue-output.outputs.linked_issues }}
steps:
- name: Get issues
id: get-issues
uses: mondeja/pr-linked-issues-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set output
id: issue-output
run: echo "linked_issues=${{ steps.get-issues.outputs.issues }}" >> $GITHUB_OUTPUT
label-issues:
name: Label linked issues
runs-on: ubuntu-latest
needs: check-linked-issues
permissions: write-all
if: github.repository == 'coronasafe/care_fe' && join(needs.check-linked-issues.outputs.linked_issues) != ''
steps:
- name: Label
uses: actions/github-script@v6
with:
script: |
const issues = "${{ needs.check-linked-issues.outputs.linked_issues }}".split(',')
for (const issue of issues) {
if ("${{ github.event.pull_request.state }}" == "open")
github.rest.issues.addLabels({
issue_number: issue,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["work-in-progress"]
})
else
github.rest.issues.removeLabel({
issue_number: issue,
owner: context.repo.owner,
repo: context.repo.repo,
name: ["work-in-progress"]
})
}