-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
fix(gh-workflow): skip comment when push directly #5853
Conversation
Size changes📦 Next.js Bundle AnalysisThis analysis was generated by the next.js bundle analysis action 🤖 This PR introduced no changes to the javascript bundle 🙌 |
with: | ||
workflow: analyze.yml | ||
branch: ${{ github.event.pull_request.base.ref }} | ||
branch: ${{ github.event.pull_request.base.ref || 'main' }} |
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.
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 comment
The 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.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
This is the key about this problem.
We should use github.event.workflow_run.workflows.event_name
instead of github.event.workflow_run.event
.
And we shouldn't use the ${{}}
, I think.
close #5801.
It works fine in zh-hans repo workflow.
I will explain my changes in code review.