Skip to content

Commit

Permalink
Try to enforce issue labeling
Browse files Browse the repository at this point in the history
  • Loading branch information
jhiemstrawisc committed Nov 27, 2024
1 parent 37b41e2 commit 23aa4c1
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/enforce-issue-labelling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Issue Validation

on:
issues:
types: [closed]

jobs:
validate-issue:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v2

- name: Validate issue has labels
id: check_labels
run: |
ISSUE_LABELS=$(jq -r '.issue.labels | length' $GITHUB_EVENT_PATH)
if [ "$ISSUE_LABELS" -eq "0" ]; then
echo "No labels found on the issue."
# Re-open the issue
ISSUE_NUMBER=$(jq -r '.issue.number' $GITHUB_EVENT_PATH)
REPO_OWNER=$(jq -r '.repository.owner.login' $GITHUB_EVENT_PATH)
REPO_NAME=$(jq -r '.repository.name' $GITHUB_EVENT_PATH)
curl -X PATCH -H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/issues/$ISSUE_NUMBER \
-d '{"state":"open"}'
exit 1
fi

0 comments on commit 23aa4c1

Please sign in to comment.