File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 5151 runs-on : ubuntu-latest
5252 permissions :
5353 contents : write
54+ issues : write # Required to update/close milestones
5455
5556 steps :
5657 - uses : actions/checkout@v4
@@ -162,3 +163,25 @@ jobs:
162163
163164 # Overwrite the existing release notes
164165 gh release edit $CURRENT_TAG --notes-file changelog.md
166+
167+ - name : Close Milestone
168+ env :
169+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
170+ run : |
171+ CURRENT_TAG=${{ github.ref_name }}
172+ VERSION_NUM=${CURRENT_TAG#v}
173+
174+ # Fetch the ID of the milestone only if it is currently open
175+ MILESTONE_ID=$(gh api repos/${{ github.repository }}/milestones -q ".[] | select(.title==\"$VERSION_NUM\" and .state==\"open\") | .number")
176+
177+ if [ -n "$MILESTONE_ID" ]; then
178+ echo "Closing milestone $VERSION_NUM (ID: $MILESTONE_ID)..."
179+ gh api \
180+ --method PATCH \
181+ -H "Accept: application/vnd.github+json" \
182+ repos/${{ github.repository }}/milestones/$MILESTONE_ID \
183+ -f state='closed'
184+ echo "Milestone closed successfully."
185+ else
186+ echo "No open milestone found matching version $VERSION_NUM. Skipping."
187+ fi
You can’t perform that action at this time.
0 commit comments