From b1dd566e06d048327f3f0398dcd69944db6f58f6 Mon Sep 17 00:00:00 2001 From: Xavi Lee <awxiaoxian2020@163.com> Date: Sat, 1 Apr 2023 01:41:00 +0000 Subject: [PATCH] fix(gh-workflow): skip comment when push directly --- .github/workflows/analyze.yml | 13 ++++++++++--- .github/workflows/analyze_comment.yml | 3 +-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/analyze.yml b/.github/workflows/analyze.yml index c447a2cdb6a..11b8177531b 100644 --- a/.github/workflows/analyze.yml +++ b/.github/workflows/analyze.yml @@ -48,10 +48,10 @@ jobs: - name: Download base branch bundle stats uses: dawidd6/action-download-artifact@v2 - if: success() && github.event.number + if: success() with: workflow: analyze.yml - branch: ${{ github.event.pull_request.base.ref }} + branch: ${{ github.event.pull_request.base.ref || 'main' }} name: bundle_analysis.json path: .next/analyze/base/bundle @@ -69,7 +69,7 @@ jobs: # Either of these arguments can be changed or removed by editing the `nextBundleAnalysis` # entry in your package.json file. - name: Compare with base branch bundle - if: success() && github.event.number + if: success() run: ls -laR .next/analyze/base && npx -p nextjs-bundle-analysis compare - name: Upload analysis comment @@ -77,6 +77,13 @@ jobs: with: name: analysis_comment.txt path: .next/analyze/__bundle_analysis_comment.txt + + number: + runs-on: ubuntu-latest + needs: analyze + if: github.event_name == 'pull_request' + steps: + - uses: actions/checkout@v2 - name: Save PR number run: echo ${{ github.event.number }} > ./pr_number diff --git a/.github/workflows/analyze_comment.yml b/.github/workflows/analyze_comment.yml index bd73b6b4ea3..da9f5f8a908 100644 --- a/.github/workflows/analyze_comment.yml +++ b/.github/workflows/analyze_comment.yml @@ -10,8 +10,7 @@ jobs: comment: runs-on: ubuntu-latest if: > - ${{ github.event.workflow_run.event == 'pull_request' && - github.event.workflow_run.conclusion == 'success' }} + github.event.workflow_run.workflows.event_name == 'pull_request' && github.event.workflow_run.workflows.conclusion == 'success' steps: - name: Download base branch bundle stats uses: dawidd6/action-download-artifact@v2