Skip to content

fix(gh-workflow): skip comment when push directly#5853

Closed
awxiaoxian2020 wants to merge 1 commit into
reactjs:mainfrom
awxiaoxian2020:gh-workflow
Closed

fix(gh-workflow): skip comment when push directly#5853
awxiaoxian2020 wants to merge 1 commit into
reactjs:mainfrom
awxiaoxian2020:gh-workflow

Conversation

@awxiaoxian2020
Copy link
Copy Markdown
Contributor

close #5801.

It works fine in zh-hans repo workflow.

I will explain my changes in code review.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 1, 2023

Size changes

Details

📦 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
Copy Markdown
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.

name: analysis_comment.txt
path: .next/analyze/__bundle_analysis_comment.txt

number:
Copy link
Copy Markdown
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.

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
Copy Markdown
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
@awxiaoxian2020 awxiaoxian2020 restored the gh-workflow branch August 17, 2025 07:29
@awxiaoxian2020 awxiaoxian2020 deleted the gh-workflow branch August 17, 2025 07:30
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