Skip to content

Commit df33a83

Browse files
committed
Add label manager
1 parent b72ff93 commit df33a83

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Autofix Label Manager
2+
3+
on:
4+
pull_request_target:
5+
types: [labeled]
6+
7+
jobs:
8+
check-to-remove-autofix-label:
9+
env:
10+
GITHUB_REPOSITORY: ${{ github.repository }}
11+
PR_NUMBER: ${{ github.event.number }}
12+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13+
REQUIRES_AUTOFIX_LABEL: "Autofix Validation Required"
14+
DOES_NOT_REQUIRE_AUTOFIX_LABEL: "No Autofix Validation Required"
15+
LABEL_ADDED: ${{ github.event.label.name }}
16+
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Check if label "No Autofix Validation Required" is added
20+
shell: bash
21+
run: |
22+
if [ "$LABEL_ADDED" != "$DOES_NOT_REQUIRE_AUTOFIX_LABEL" ]; then
23+
echo "Label $DOES_NOT_REQUIRE_AUTOFIX_LABEL was not added."
24+
exit 0
25+
fi
26+
27+
echo "Label $DOES_NOT_REQUIRE_AUTOFIX_LABEL was added."
28+
29+
# Check if Label $REQUIRES_AUTOFIX_LABEL exists and remove it
30+
REQUIRES_AUTOFIX_LABEL_EXISTS=$(gh api /repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/labels | jq --arg label "Autofix Validation Required" '.[] | select(.name==$label) | .name')
31+
if [ "$REQUIRES_AUTOFIX_LABEL_EXISTS" == "$REQUIRES_AUTOFIX_LABEL" ]; then
32+
gh api -X DELETE "/repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/labels/$REQUIRES_AUTOFIX_LABEL"
33+
echo "$REQUIRES_AUTOFIX_LABEL Label removed."
34+
else
35+
echo "$REQUIRES_AUTOFIX_LABEL Label does not exist or was already removed."
36+
fi

.github/workflows/autofix-reminder.yml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ permissions:
88
issues: write
99

1010
on:
11+
workflow_dispatch:
1112
pull_request:
1213
branches:
1314
- main

0 commit comments

Comments
 (0)