Comment on pull request #316
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 pull request | |
on: | |
workflow_run: | |
workflows: | |
- Check type sizes | |
types: | |
- completed | |
jobs: | |
run: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download artifact | |
uses: dawidd6/action-download-artifact@v2 | |
with: | |
workflow: .github/workflows/check-type-sizes.yml | |
run_id: ${{ github.event.workflow_run.id }} | |
name: comment-info.json | |
- name: Format comment | |
id: format | |
run: | | |
set -ex | |
body="$(jq --raw-output .comment comment-info.json)" | |
body="${body//'%'/'%25'}" | |
body="${body//$'\n'/'%0A'}" | |
body="${body//$'\r'/'%0D'}" | |
echo "::set-output name=body::$body" | |
echo "COMMENT_SEARCH=$(jq --raw-output .comment_search comment-info.json)" >> $GITHUB_ENV | |
echo "COMMENT_PR_NUMBER=$(jq --raw-output .pr_number comment-info.json)" >> $GITHUB_ENV | |
echo "COMMENT_UPDATE_ONLY=$(jq --raw-output 'if .update_only then 1 else 0 end' comment-info.json)" >> $GITHUB_ENV | |
- name: Find existing comment | |
id: find_comment | |
uses: peter-evans/find-comment@v1 | |
with: | |
issue-number: ${{ env.COMMENT_PR_NUMBER }} | |
comment-author: github-actions[bot] | |
body-includes: ${{ env.COMMENT_SEARCH }} | |
- name: Post comment | |
if: ${{ env.COMMENT_UPDATE_ONLY != 1 || steps.find_comment.outputs.comment-id != '' }} | |
uses: peter-evans/create-or-update-comment@v1 | |
with: | |
issue-number: ${{ env.COMMENT_PR_NUMBER }} | |
comment-id: ${{ steps.find_comment.outputs.comment-id }} | |
body: ${{ steps.format.outputs.body }} | |
edit-mode: replace |