Skip to content

345 infrastructure add report bug button #28

345 infrastructure add report bug button

345 infrastructure add report bug button #28

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
});