Analyze Bundle (Comment) #36
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: Analyze Bundle (Comment) | |
on: | |
workflow_run: | |
workflows: ["Analyze Bundle"] | |
types: | |
- completed | |
jobs: | |
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: | |
workflow: analyze.yml | |
run_id: ${{ github.event.workflow_run.id }} | |
name: analysis_comment.txt | |
path: analysis_comment.txt | |
- name: Download PR number | |
uses: dawidd6/action-download-artifact@v2 | |
with: | |
workflow: analyze.yml | |
run_id: ${{ github.event.workflow_run.id }} | |
name: pr_number | |
path: pr_number | |
- name: Get comment body | |
id: get-comment-body | |
if: success() | |
run: | | |
echo 'body<<EOF' >> $GITHUB_OUTPUT | |
echo '' >> $GITHUB_OUTPUT | |
echo '## Size changes' >> $GITHUB_OUTPUT | |
echo '' >> $GITHUB_OUTPUT | |
echo '<details>' >> $GITHUB_OUTPUT | |
echo '' >> $GITHUB_OUTPUT | |
cat analysis_comment.txt/__bundle_analysis_comment.txt >> $GITHUB_OUTPUT | |
echo '' >> $GITHUB_OUTPUT | |
echo '</details>' >> $GITHUB_OUTPUT | |
echo '' >> $GITHUB_OUTPUT | |
echo 'EOF' >> $GITHUB_OUTPUT | |
pr_number=$(cat pr_number/pr_number) | |
echo "pr-number=$pr_number" >> $GITHUB_OUTPUT | |
- name: Find Comment | |
uses: peter-evans/find-comment@v1 | |
if: success() | |
id: fc | |
with: | |
issue-number: ${{ steps.get-comment-body.outputs.pr-number }} | |
body-includes: "<!-- __NEXTJS_BUNDLE -->" | |
- name: Create Comment | |
uses: peter-evans/[email protected] | |
if: success() && steps.fc.outputs.comment-id == 0 | |
with: | |
issue-number: ${{ steps.get-comment-body.outputs.pr-number }} | |
body: ${{ steps.get-comment-body.outputs.body }} | |
- name: Update Comment | |
uses: peter-evans/[email protected] | |
if: success() && steps.fc.outputs.comment-id != 0 | |
with: | |
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 |