-
Notifications
You must be signed in to change notification settings - Fork 7.7k
fix(gh-workflow): skip comment when push directly #5853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,14 +69,21 @@ 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 | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: analysis_comment.txt | ||
path: .next/analyze/__bundle_analysis_comment.txt | ||
|
||
number: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't upload the pr_number when we push directly. So I split a new job and add a condition in order to run it on pull_request only. |
||
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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the key about this problem. We should use And we shouldn't use the |
||
steps: | ||
- name: Download base branch bundle stats | ||
uses: dawidd6/action-download-artifact@v2 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we push directly, we use main branch.