-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Auto-link / Close Issues for 2.0 PRs (p5.js & p5.js-website) #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
Changes from 10 commits
24ba4a0
1e033ca
d5b64c7
bf6b5a7
f652ca1
d041b1c
d2d1ead
0d5477a
6cfe0fe
74ae50c
203254b
86bf86a
bf63f55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
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 = /(Fixes|Resolves|Closes)\s+#(\d+)/gi; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: consider making more flexible? Eg There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aah, yes, that sounds great to me and also very flexible as well. It would help ensure consistency with the main branch’s behavior. |
||
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" | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍