Skip to content

Commit

Permalink
PLAY-1526 Add comment when merge master (#3727)
Browse files Browse the repository at this point in the history
**What does this PR do?** A clear and concise description with your
runway ticket url.
Runway https://runway.powerhrg.com/backlog_items/PLAY-1526
A 2nd failed attempt to get a comment after squash and merge master here
#3720

This is try number 3 

This is a screenshot of me getting comment to automatically show up
after i merge master. It was done on my own private repo so it didn't
have the fancy github action user sorry mom


![screenshot-github_com-2024_09_25-13_22_51](https://github.com/user-attachments/assets/5e0c9e5e-8e9b-4383-9535-0bf33290ca01)

You can also comments in this PR

---------

Co-authored-by: Jasper Furniss <[email protected]>
  • Loading branch information
markdoeswork and jasperfurniss authored Sep 30, 2024
1 parent 81f360d commit 09a6ec7
Showing 1 changed file with 36 additions and 5 deletions.
41 changes: 36 additions & 5 deletions .github/workflows/github-actions-release-candidate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,46 @@ jobs:
--notes "This is a release candidate version. Please test thoroughly before promoting to a stable release." \
--prerelease
- name: Leave PR comment
uses: actions/github-script@v6
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUBY_GEM_VERSION: ${{ env.new_ruby_version }}
RUBY_GEM_LINK: https://rubygems.org/gems/playbook_ui/versions/${{env.new_ruby_version}}
NPM_VERSION: ${{ env.new_npm_version }}
NPM_LINK: https://www.npmjs.com/package/playbook-ui/v/${{env.new_npm_version}}
run: |
curl -H "Authorization: token ${GITHUB_TOKEN}" \
-X POST \
-d '{"body": "Release Candidate Created \n\n Your RC for Ruby Gems is [${{env.RUBY_GEM_VERSION}}](${{env.RUBY_GEM_LINK}}) \n\n Your RC for NPM is [${{env.NPM_VERSION}}](${{env.NPM_LINK}}) "}' \
"https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const commitSha = context.payload.head_commit.id;
const commitMessage = context.payload.head_commit.message;
const commitAuthor = context.payload.head_commit.author.name;
const commitUrl = context.payload.head_commit.url;
console.log(`Commit message: ${commitMessage}`);
console.log(`Commit author: ${commitAuthor}`);
console.log(`Commit URL: ${commitUrl}`);
// Get the PR related to this commit using octokit API
const pullRequests = await github.rest.repos.listPullRequestsAssociatedWithCommit({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: commitSha
});
if (pullRequests.data.length > 0) {
const pullRequestNumber = pullRequests.data[0].number;
console.log(`Found pull request #${pullRequestNumber} for commit ${commitSha}`);
// Add a comment to the pull request
await github.rest.issues.createComment({
issue_number: pullRequestNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body: `You merged this pr to master branch:
- Ruby Gem: [${{env.RUBY_GEM_VERSION}}](${{env.RUBY_GEM_LINK}})
- NPM: [${{env.NPM_VERSION}}](${{env.NPM_LINK}})`
});
} else {
console.log('No pull request found for this commit');
}

0 comments on commit 09a6ec7

Please sign in to comment.