Skip to content

Commit

Permalink
Comment on PRs when released
Browse files Browse the repository at this point in the history
  • Loading branch information
bradymholt authored Jul 9, 2024
1 parent 10e81f9 commit fa51169
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,34 @@ jobs:
name: npm-logs
path: ~/.npm/_logs
- name: Create a Release
id: create-release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.push.outputs.tag-name }}
generate_release_notes: true
generate_release_notes: true
- name: Comment on PRs with link to release they are included in
uses: actions/github-script@v6
env:
RELEASE_ID: ${{ steps.create-release.outputs.id }}
with:
script: |
const releaseId = process.env.RELEASE_ID;
console.log(`Fetching release_id: ${releaseId} ...`);
const getReleaseResponse = await github.rest.repos.getRelease({
release_id: process.env.RELEASE_ID,
owner: context.repo.owner,
repo: context.repo.repo
});
const release = getReleaseResponse.data;
const prNumbersInRelease = new Set(Array.from(release.body.matchAll(/\/pull\/(\d+)/g)).map(p=>p[1]));
for(let prNumber of prNumbersInRelease) {
console.log(`Adding comment on PR #${prNumber} ...`);
await github.rest.issues.createComment({
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body: `The changes in this PR were just released in [${release.name}](https://github.com/${context.repo.owner}/${context.repo.repo}/releases/tag/${release.tag_name}) 🎉.`
})
}

0 comments on commit fa51169

Please sign in to comment.