Browse Source

Try to fix it

main
Dan Abramov 4 years ago
parent
commit
25ac9d06da
  1. 19
      .github/workflows/analyze.yml
  2. 32
      .github/workflows/analyze_comment.yml

19
.github/workflows/bundle_analysis_upload.yml → .github/workflows/analyze.yml

@ -1,5 +1,11 @@
name: Bundle Analysis Upload name: Analyze Bundle
on: pull_request
on:
pull_request:
push:
branches:
- main # change this if your default branch is named differently
workflow_dispatch:
jobs: jobs:
analyze: analyze:
@ -77,5 +83,14 @@ jobs:
name: analysis_comment.txt name: analysis_comment.txt
path: beta/.next/analyze/__bundle_analysis_comment.txt path: beta/.next/analyze/__bundle_analysis_comment.txt
- name: Save PR number
run: echo ${{ github.event.number }} > ./pr-number
- name: Upload PR number
uses: actions/upload-artifact@v2
with:
name: pr-number
path: ./pr-number
# The actual commenting happens in the other action, matching the guidance in # The actual commenting happens in the other action, matching the guidance in
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ # https://securitylab.github.com/research/github-actions-preventing-pwn-requests/

32
.github/workflows/bundle_analysis_comment.yml → .github/workflows/analyze_comment.yml

@ -1,13 +1,13 @@
name: Bundle Analysis Comment name: Analyze Bundle (Comment)
on: on:
workflow_run: workflow_run:
workflows: ["Bundle Analysis Upload"] workflows: ["Analyze Bundle"]
types: types:
- completed - completed
jobs: jobs:
comment: upload:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: > if: >
${{ github.event.workflow_run.event == 'pull_request' && ${{ github.event.workflow_run.event == 'pull_request' &&
@ -15,16 +15,23 @@ jobs:
steps: steps:
- name: Download base branch bundle stats - name: Download base branch bundle stats
uses: dawidd6/action-download-artifact@v2 uses: dawidd6/action-download-artifact@v2
if: success() && github.event.number
with: with:
workflow: bundle_analysis_upload.yml workflow: analyze.yml
name: analysis_comment.txt name: analysis_comment.txt
path: analysis_comment.txt path: analysis_comment.txt
- name: Download PR number
uses: dawidd6/action-download-artifact@v2
with:
workflow: analyze.yml
name: pr_number
path: pr_number
- name: Get comment body - name: Get comment body
id: get-comment-body id: get-comment-body
if: success() && github.event.number if: success()
run: | run: |
pr_number=$(cat pr_number)
body=$(cat analysis_comment.txt) body=$(cat analysis_comment.txt)
body="## Size Changes body="## Size Changes
<details> <details>
@ -36,28 +43,29 @@ jobs:
body="${body//$'\n'/'%0A'}" body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}" body="${body//$'\r'/'%0D'}"
echo ::set-output name=body::$body echo ::set-output name=body::$body
echo ::set-output name=pr-number::$pr_number
working-directory: beta working-directory: beta
- name: Find Comment - name: Find Comment
uses: peter-evans/find-comment@v1 uses: peter-evans/find-comment@v1
if: success() && github.event.number if: success()
id: fc id: fc
with: with:
issue-number: ${{ github.event.number }} issue-number: ${{ steps.get-comment-body.outputs.pr-number }}
body-includes: "<!-- __NEXTJS_BUNDLE -->" body-includes: "<!-- __NEXTJS_BUNDLE -->"
- name: Create Comment - name: Create Comment
uses: peter-evans/create-or-update-comment@v1.4.4 uses: peter-evans/create-or-update-comment@v1.4.4
if: success() && github.event.number && steps.fc.outputs.comment-id == 0 if: success() && steps.fc.outputs.comment-id == 0
with: with:
issue-number: ${{ github.event.number }} issue-number: ${{ steps.get-comment-body.outputs.pr-number }}
body: ${{ steps.get-comment-body.outputs.body }} body: ${{ steps.get-comment-body.outputs.body }}
- name: Update Comment - name: Update Comment
uses: peter-evans/create-or-update-comment@v1.4.4 uses: peter-evans/create-or-update-comment@v1.4.4
if: success() && github.event.number && steps.fc.outputs.comment-id != 0 if: success() && steps.fc.outputs.comment-id != 0
with: with:
issue-number: ${{ github.event.number }} issue-number: ${{ steps.get-comment-body.outputs.pr-number }}
body: ${{ steps.get-comment-body.outputs.body }} body: ${{ steps.get-comment-body.outputs.body }}
comment-id: ${{ steps.fc.outputs.comment-id }} comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace edit-mode: replace
Loading…
Cancel
Save