Comment on pull request #272
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 | |
path: downloads | |
- name: Extract artifact | |
id: extract | |
run: | | |
set -ex | |
body="$(jq --raw-output .comment downloads/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 downloads/comment-info.json)" >> $GITHUB_ENV | |
echo "COMMENT_PR_NUMBER=$(jq --raw-output .pr_number downloads/comment-info.json)" >> $GITHUB_ENV | |
echo "COMMENT_UPDATE_ONLY=$(jq --raw-output 'if .update_only then 1 else 0 end' downloads/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.extract.outputs.body }} | |
edit-mode: replace |