Skip to content

PR Comment

PR Comment #380

Workflow file for this run

# Automatically posts comments on pull requests with messages generated by other workflows
# Triggered when specified workflows complete successfully
name: PR Comment
on: # yamllint disable-line rule:truthy
workflow_run:
# NOTE: Add any workflow that needs to comment on PRs to this list
workflows:
- Check Config Changes
- Profiling Report
types:
- completed
# default permissions as read only
permissions: read-all
jobs:
comment-on-pr:
permissions:
pull-requests: write
runs-on: ubuntu-latest
# Only run if the triggering workflow succeeded
if: github.event.workflow_run.conclusion == 'success'
steps:
# Download the message artifact created by the triggering workflow
- name: Download comment message
id: download-artifact
continue-on-error: true
uses: actions/download-artifact@v6
with:
name: message
path: /tmp/
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Extract PR number from filename
if: steps.download-artifact.outcome == 'success'
id: extract-pr
run: |
echo "message-file=$(ls /tmp/message*.txt)" >> $GITHUB_OUTPUT
echo "pr-number=$(echo /tmp/message*.txt | sed -E 's/.*message-([0-9]+)\.txt/\1/')" >> $GITHUB_OUTPUT
- name: Comment on PR
if: steps.download-artifact.outcome == 'success' && steps.extract-pr.outputs.pr-number != ''
uses: thollander/actions-comment-pull-request@v3
with:
file-path: ${{ steps.extract-pr.outputs.message-file }}
github-token: ${{ secrets.GITHUB_TOKEN }}
pr-number: ${{ steps.extract-pr.outputs.pr-number }}
reactions: eyes, rocket