Skip to content

Solves Issue 7975 #8025

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: dev-2.0
Choose a base branch
from
Open
38 changes: 38 additions & 0 deletions .github/workflows/auto-close-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Close Linked Issues on PR Merge

on:
pull_request:
types:
- closed
branches:
- 2.0
- dev-2.0

jobs:
close_issues:
if: github.event.pull_request.merged == true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

runs-on: ubuntu-latest
steps:
- name: Extract and Close Issues
uses: actions/github-script@v7
with:
script: |
const prBody = context.payload.pull_request.body;
const issueRegex = /\b(close[sd]?|fix(e[sd])?|resolve[sd]?)[:\s]*#(\d+)\b/gi;
let match;
while ((match = issueRegex.exec(prBody)) !== null) {
const issueNumber = parseInt(match[2], 10);
console.log(`Closing issue #${issueNumber}`);
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
body: `Closed by merged PR #${context.payload.pull_request.number}`
});
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
state: "closed"
});
}
Loading