You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.2 KiB

3 years ago
name: Analyze Bundle (Comment)
on:
workflow_run:
3 years ago
workflows: ["Analyze Bundle"]
types:
- completed
jobs:
3 years ago
comment:
runs-on: ubuntu-latest
if: >
${{ github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Download base branch bundle stats
uses: dawidd6/action-download-artifact@v2
with:
3 years ago
workflow: analyze.yml
3 years ago
run_id: ${{ github.event.workflow_run.id }}
name: analysis_comment.txt
path: analysis_comment.txt
3 years ago
- name: Download PR number
uses: dawidd6/action-download-artifact@v2
with:
workflow: analyze.yml
3 years ago
run_id: ${{ github.event.workflow_run.id }}
3 years ago
name: pr_number
path: pr_number
- name: Get comment body
id: get-comment-body
3 years ago
if: success()
run: |
3 years ago
pr_number=$(cat pr_number/pr_number)
body=$(cat analysis_comment.txt/__bundle_analysis_comment.txt)
body="## Size Changes
<details>
${body}
</details>"
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo ::set-output name=body::$body
3 years ago
echo ::set-output name=pr-number::$pr_number
- name: Find Comment
uses: peter-evans/find-comment@v1
3 years ago
if: success()
id: fc
with:
3 years ago
issue-number: ${{ steps.get-comment-body.outputs.pr-number }}
body-includes: "<!-- __NEXTJS_BUNDLE -->"
- name: Create Comment
uses: peter-evans/create-or-update-comment@v1.4.4
3 years ago
if: success() && steps.fc.outputs.comment-id == 0
with:
3 years ago
issue-number: ${{ steps.get-comment-body.outputs.pr-number }}
body: ${{ steps.get-comment-body.outputs.body }}
- name: Update Comment
uses: peter-evans/create-or-update-comment@v1.4.4
3 years ago
if: success() && steps.fc.outputs.comment-id != 0
with:
3 years ago
issue-number: ${{ steps.get-comment-body.outputs.pr-number }}
body: ${{ steps.get-comment-body.outputs.body }}
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace