Merge pull request #116 from scub-france/ci/auto-close-issues
ci: auto-close issues on merge into release/* branches
This commit is contained in:
commit
d62af058ed
1 changed files with 43 additions and 0 deletions
43
.github/workflows/auto-close-issues.yml
vendored
Normal file
43
.github/workflows/auto-close-issues.yml
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
name: Auto-close issues on release branch merge
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'release/**'
|
||||
|
||||
permissions:
|
||||
issues: write
|
||||
|
||||
jobs:
|
||||
close-issues:
|
||||
name: Close referenced issues
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Scan commits and close issues
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
REPO: ${{ github.repository }}
|
||||
SHA: ${{ github.sha }}
|
||||
run: |
|
||||
# Collect all commit messages from the push event
|
||||
commits='${{ toJSON(github.event.commits) }}'
|
||||
|
||||
# Extract issue numbers from Closes/Fixes patterns (case-insensitive)
|
||||
issues=$(echo "$commits" \
|
||||
| grep -ioE '(closes|fixes|close|fix|resolved|resolves)\s+#[0-9]+' \
|
||||
| grep -oE '[0-9]+' \
|
||||
| sort -u)
|
||||
|
||||
if [ -z "$issues" ]; then
|
||||
echo "No issue references found in commit messages."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
branch="${GITHUB_REF#refs/heads/}"
|
||||
for issue in $issues; do
|
||||
echo "Closing issue #$issue (referenced in $branch @ ${SHA:0:7})"
|
||||
gh issue close "$issue" \
|
||||
--repo "$REPO" \
|
||||
--comment "Closed automatically — merged into \`$branch\` via ${SHA:0:7}." \
|
||||
|| echo "Warning: could not close #$issue (may already be closed)"
|
||||
done
|
||||
Loading…
Reference in a new issue