Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

awxiaoxian2020
Copy link
Contributor

close #5801.

It works fine in zh-hans repo workflow.

I will explain my changes in code review.

@github-actions
Copy link

github-actions bot commented Apr 1, 2023

Size changes

📦 Next.js Bundle Analysis

This 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' }}
Copy link
Contributor Author

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:
Copy link
Contributor Author

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'
Copy link
Contributor Author

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.

@awxiaoxian2020 awxiaoxian2020 deleted the gh-workflow branch April 2, 2023 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[GH workflow] update analyze.yml to avoid noisy notification
2 participants