Skip to content

Commit

Permalink
Add label manager
Browse files Browse the repository at this point in the history
  • Loading branch information
aeisenberg committed Jul 18, 2024
1 parent b72ff93 commit df33a83
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/autofix-label-manager.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Autofix Label Manager

on:
pull_request_target:
types: [labeled]

jobs:
check-to-remove-autofix-label:
env:
GITHUB_REPOSITORY: ${{ github.repository }}
PR_NUMBER: ${{ github.event.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REQUIRES_AUTOFIX_LABEL: "Autofix Validation Required"
DOES_NOT_REQUIRE_AUTOFIX_LABEL: "No Autofix Validation Required"
LABEL_ADDED: ${{ github.event.label.name }}

runs-on: ubuntu-latest
steps:
- name: Check if label "No Autofix Validation Required" is added
shell: bash
run: |
if [ "$LABEL_ADDED" != "$DOES_NOT_REQUIRE_AUTOFIX_LABEL" ]; then
echo "Label $DOES_NOT_REQUIRE_AUTOFIX_LABEL was not added."
exit 0
fi
echo "Label $DOES_NOT_REQUIRE_AUTOFIX_LABEL was added."
# Check if Label $REQUIRES_AUTOFIX_LABEL exists and remove it
REQUIRES_AUTOFIX_LABEL_EXISTS=$(gh api /repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/labels | jq --arg label "Autofix Validation Required" '.[] | select(.name==$label) | .name')
if [ "$REQUIRES_AUTOFIX_LABEL_EXISTS" == "$REQUIRES_AUTOFIX_LABEL" ]; then
gh api -X DELETE "/repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/labels/$REQUIRES_AUTOFIX_LABEL"
echo "$REQUIRES_AUTOFIX_LABEL Label removed."
else
echo "$REQUIRES_AUTOFIX_LABEL Label does not exist or was already removed."
fi
1 change: 1 addition & 0 deletions .github/workflows/autofix-reminder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ permissions:
issues: write

on:
workflow_dispatch:
pull_request:
branches:
- main
Expand Down

0 comments on commit df33a83

Please sign in to comment.