Skip to content

Commit f89a2b4

Browse files
committed
Update release-and-pypi-publish.yml
1 parent 8e27f78 commit f89a2b4

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

.github/workflows/release-and-pypi-publish.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,35 @@ jobs:
100100
git tag $NEW_VERSION
101101
git push origin main --tags
102102
103+
- name: Label linked issues as merged
104+
if: github.event.pull_request.merged == true && github.ref == 'refs/heads/main'
105+
uses: actions/github-script@v5
106+
with:
107+
github-token: ${{ secrets.GITHUB_TOKEN }}
108+
script: |
109+
const github = require('@actions/github');
110+
const context = github.context;
111+
const pullRequest = context.payload.pull_request;
112+
113+
// Regex to extract linked issue numbers from PR body
114+
const issueRegex = /(?:fixes|resolves|closes) #(\d+)/gi;
115+
let match;
116+
const issueNumbers = [];
117+
118+
while ((match = issueRegex.exec(pullRequest.body)) !== null) {
119+
issueNumbers.push(match[1]);
120+
}
121+
122+
// Add a label to each linked issue
123+
for (const issueNumber of issueNumbers) {
124+
await github.rest.issues.addLabels({
125+
owner: context.repo.owner,
126+
repo: context.repo.repo,
127+
issue_number: issueNumber,
128+
labels: ['merged to main']
129+
});
130+
}
131+
103132
- name: Generate changelog
104133
if: steps.check.outputs.skip != 'true'
105134
uses: heinrichreimer/[email protected]

0 commit comments

Comments
 (0)