345 infrastructure add report bug button #28
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Comment on Issue When PR is Merged | |
on: | |
pull_request: | |
types: [closed] | |
permissions: | |
issues: write | |
pull-requests: read | |
jobs: | |
comment: | |
runs-on: ubuntu-latest | |
if: github.event.pull_request.merged == true | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Get Issue Number | |
id: get-issue-number | |
run: | | |
if [ -z "${{ github.event.pull_request.body }}" ]; then | |
echo "No issue number found in PR body (PR body is empty)" | |
echo "issue_number=null" >> $GITHUB_ENV | |
else | |
ISSUE_NUMBER=$(echo "${{ github.event.pull_request.body }}" | grep -oP '(?<=#)\d+') | |
if [ -n "$ISSUE_NUMBER" ]; then | |
echo "::set-output name=issue_number::$ISSUE_NUMBER" | |
else | |
echo "No issue number found in PR body" | |
echo "issue_number=null" >> $GITHUB_ENV | |
exit 0 | |
fi | |
fi | |
- name: Comment on Issue | |
if: env.issue_number != 'null' | |
uses: actions/github-script@v5 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const issueNumber = '${{ steps.get-issue-number.outputs.issue_number }}'; | |
const issue = await github.rest.issues.get({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issueNumber | |
}); | |
const contributor = issue.data.user.login; | |
const greetingMessage = `@${contributor}, Thank you so much for your contribution! π Your help is greatly appreciated. If you could share this project with your community, it would mean a lot. π Additionally, if you have any suggestions for improvements, please feel free to share. π‘ Looking forward to more collaborations! π`; | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issueNumber, | |
body: greetingMessage | |
}); |