Reopens any issue that is closed as completed without a milestone assigned, after a short grace period to allow for the milestone being set immediately after closure.
This commit is contained in:
parent
5fba79c4ca
commit
c1135de8f5
|
|
@ -0,0 +1,37 @@
|
|||
name: Enforce milestone on close
|
||||
|
||||
on:
|
||||
issues:
|
||||
types:
|
||||
- closed
|
||||
|
||||
permissions:
|
||||
issues: write
|
||||
|
||||
jobs:
|
||||
check-milestone:
|
||||
name: Check Milestone
|
||||
if: github.repository == 'netbox-community/netbox' && github.event.issue.state_reason == 'completed'
|
||||
runs-on: ubuntu-slim
|
||||
|
||||
steps:
|
||||
- name: Reopen issues completed without a milestone
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
ISSUE: ${{ github.event.issue.number }}
|
||||
run: |
|
||||
# Grace period, in case the milestone is assigned immediately after closure
|
||||
sleep 90
|
||||
|
||||
# Re-check the issue: bail out if it has been reopened or a milestone has since been set
|
||||
DATA=$(gh issue view "$ISSUE" --json state,milestone)
|
||||
STATE=$(jq -r '.state' <<< "$DATA")
|
||||
MILESTONE=$(jq -r '.milestone.title // ""' <<< "$DATA")
|
||||
if [ "$STATE" != "CLOSED" ] || [ -n "$MILESTONE" ]; then
|
||||
echo "Nothing to do (state=$STATE, milestone=${MILESTONE:-none})"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
gh issue reopen "$ISSUE" --comment \
|
||||
"This issue was closed as completed without a milestone assigned, and has been reopened automatically. Please assign the milestone for the upcoming release, then close the issue again."
|
||||
Loading…
Reference in New Issue