-
Notifications
You must be signed in to change notification settings - Fork 3
61 lines (53 loc) · 1.7 KB
/
swap-labels.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
# **what?**
# Will remove one label in favor of another
#
# **why?**
# When we triage issues, we sometimes need more information from the issue creator. In
# those cases we remove the `triage` label and add the `awaiting_response` label. Once we
# receive a response in the form of a comment, we want the `awaiting_response` label removed
# in favor of the `triage` label so we are aware that the issue needs action.
# **when?**
# This will run when called by another workflow
name: Swap Issue Labels
on:
workflow_call:
inputs:
add_label:
description: The label to add
type: string
required: true
remove_label:
description: The label to remove
type: string
required: true
defaults:
run:
shell: bash
permissions:
issues: write
jobs:
triage_label:
# only swap the labels if the label to remove exists
if: contains(github.event.issue.labels.*.name, '${{ inputs.remove_label }}')
runs-on: ubuntu-latest
steps:
- name: "Add ${{ inputs.add_label }} label"
uses: actions/github-script@v7
with:
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["${{ inputs.add_label }}"]
})
- name: "Remove ${{ inputs.remove_label }} label"
uses: actions/github-script@v7
with:
script: |
github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: ["${{ inputs.remove_label }}"]
})