Skip to content

Commit

Permalink
Add issue labelling enforcement
Browse files Browse the repository at this point in the history
  • Loading branch information
jhiemstrawisc committed Nov 27, 2024
1 parent 37b41e2 commit 9d307ab
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/enforce-PR-labelling.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PR and Issue Validation
name: PR Validation

on:
pull_request:
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/enforce-issue-labelling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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 -L \
-X PATCH \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/issues/$ISSUE_NUMBER \
-d '{"state":"open"}'
exit 1
fi

0 comments on commit 9d307ab

Please sign in to comment.