-
Notifications
You must be signed in to change notification settings - Fork 459
79 lines (67 loc) · 2.42 KB
/
autolabel.yaml
File metadata and controls
79 lines (67 loc) · 2.42 KB
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
77
78
79
name: Update issue labels
on:
issue_comment:
types: [created]
concurrency:
group: ${{ github.workflow }}-${{ github.event.issue.number }}
cancel-in-progress: true
# Define labels here
env:
AWAITING_RESPONSE: stat:awaiting response
jobs:
setup:
name: Calculate Labels
if: ${{ !github.event.issue.pull_request }} && ${{ github.event.issue.state == 'open' }}
runs-on: ubuntu-latest
outputs:
add_labels: ${{ steps.data.outputs.add_labels }}
remove_labels: ${{ steps.data.outputs.remove_labels }}
steps:
- name: Calculate Labels
id: data
run: |
ADD_LABELS=()
REMOVE_LABELS=()
if [[ "${{ github.event.comment.author_association }}" == "MEMBER" ]]; then
ADD_LABELS+=${{ env.AWAITING_RESPONSE}}
else
REMOVE_LABELS+=${{ env.AWAITING_RESPONSE}}
fi
echo "add_labels=$(IFS=,; echo "${ADD_LABELS[*]}")" >> $GITHUB_OUTPUT
echo "remove_labels=$(IFS=,; echo "${REMOVE_LABELS[*]}")" >> $GITHUB_OUTPUT
manage_labels:
runs-on: ubuntu-latest
permissions:
issues: write
needs: [setup]
steps:
- name: Calculate add labels
id: add_labels
if: ${{ needs.setup.outputs.add_labels != '' }}
run: |
COMMAND=""
if [[ -n "${{ needs.setup.outputs.add_labels }}" ]]; then
COMMAND+="--add-label \"${{ needs.setup.outputs.add_labels }}\""
fi
echo "ADD_LABEL=$COMMAND" >> $GITHUB_ENV
- name: Calculate remove labels
id: remove_labels
if: ${{ needs.setup.outputs.remove_labels != '' }}
run: |
COMMAND=""
if [[ -n "${{ needs.setup.outputs.remove_labels }}" ]]; then
COMMAND+="--remove-label \"${{ needs.setup.outputs.remove_labels }}\""
fi
echo "REMOVE_LABEL=$COMMAND" >> $GITHUB_ENV
- name: Test Print Command
run: |
echo "gh issue edit "$NUMBER" $ADD_LABEL $REMOVE_LABEL"
env:
NUMBER: ${{ github.event.issue.number }}
# - run: gh issue edit "$NUMBER" --add-label "$ADD_LABELS" --remove-label "$REMOVE_LABELS"
# env:
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# GH_REPO: ${{ github.repository }}
# NUMBER: ${{ github.event.issue.number }}
# ADD_LABELS: ${{ needs.setup.outputs.add_labels }}
# REMOVE_LABELS: ${{ needs.setup.outputs.remove_labels }}