Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/enforce-milestone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
name: Enforce milestone on close

"on":
issues:
types:
- closed

permissions:
issues: write

jobs:
check-milestone:
name: Check Milestone
if: >-
github.repository == 'netbox-community/netbox-scripts' &&
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 }}
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.
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 "$COMMENT"
Loading