mirror of
https://github.com/gwdevhub/Daybreak.git
synced 2026-07-15 15:19:57 +00:00
Label merged issues (#1301)
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
name: Label Merged Issues
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [closed]
|
||||
branches:
|
||||
- 'release/**'
|
||||
|
||||
jobs:
|
||||
label-issues:
|
||||
if: github.event.pull_request.merged == true
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Label linked issues as merged
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const prBody = context.payload.pull_request.body || '';
|
||||
const prTitle = context.payload.pull_request.title || '';
|
||||
|
||||
// Match issue references like #123, fixes #123, closes #123, resolves #123
|
||||
const issuePattern = /(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)?[\s:]*#(\d+)/gi;
|
||||
const issueNumbers = new Set();
|
||||
|
||||
// Search in PR body and title
|
||||
const textToSearch = `${prTitle} ${prBody}`;
|
||||
let match;
|
||||
while ((match = issuePattern.exec(textToSearch)) !== null) {
|
||||
issueNumbers.add(parseInt(match[1]));
|
||||
}
|
||||
|
||||
// Apply 'merged' label to each linked issue
|
||||
for (const issueNumber of issueNumbers) {
|
||||
try {
|
||||
await github.rest.issues.addLabels({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issueNumber,
|
||||
labels: ['merged']
|
||||
});
|
||||
console.log(`Added 'merged' label to issue #${issueNumber}`);
|
||||
} catch (error) {
|
||||
console.log(`Failed to label issue #${issueNumber}: ${error.message}`);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -8,12 +8,12 @@
|
||||
<File Path=".github/workflows/ci.yaml" />
|
||||
<File Path=".github/workflows/codeql-analysis.yml" />
|
||||
<File Path=".github/workflows/version_check.yaml" />
|
||||
<File Path="mark-issues-merged.yml" />
|
||||
</Folder>
|
||||
<Folder Name="/Scripts/">
|
||||
<File Path="Scripts/BuildRelease.ps1" />
|
||||
<File Path="Scripts/CompareVersions.ps1" />
|
||||
<File Path="Scripts/GetBuildVersion.ps1" />
|
||||
<File Path="Scripts/PushFilesToBlobStorage.ps1" />
|
||||
</Folder>
|
||||
<Folder Name="/Solution Items/">
|
||||
<File Path=".editorconfig" />
|
||||
|
||||
Reference in New Issue
Block a user