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 #6179

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

awxiaoxian2020
Copy link
Contributor

close #5801.

The workaround is fine in zh-hans.react.dev now.

@github-actions
Copy link

github-actions bot commented Jul 25, 2023

Size changes

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

@awxiaoxian2020
Copy link
Contributor Author

Who can follow this PR?

@awxiaoxian2020
Copy link
Contributor Author

PTAL.

Comment on lines -12 to -14
if: >
${{ github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success' }}
Copy link
Contributor

@alinkedd alinkedd Feb 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the core problem lies in the evaluation of these lines by GitHub's runner. If github.event.workflow_run.event is not even the right parameter (as you implied in another PR), then this job should never run. Nevertheless, it runs, meaning that the condition is always set to true somehow - just like here: actions/runner#1173. Presumably, ${{ and }} syntax along with block formatting sign > result in the text, thus making it a truthy value.

Did you try other variations of that condition without the block sign > and with event_name like this?

if: github.event.workflow_run.event_name == 'pull_request' && github.event.workflow_run.conclusion == 'success'

P.S.
Regarding the PR itself, I think we still need the if success check for the entire comment job. Otherwise, the remaining Comment step is going to produce an error in case steps.get-comment-body.outputs is empty.

P.P.S.
Also, I was thinking that ignoring the default branch for this workflow can serve as an additional precaution as well:

on:
  workflow_run:
    workflows: ["Analyze Bundle"]
    types:
      - completed
    branches-ignore:
      - main # change this if your default branch is named differently

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually checked and this did the trick:

if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'

event is the right property and the evaluation is indeed broken.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually checked and this did the trick:

How do you check this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alinkedd I remember > was used for multiline?

also I checked what other option we have for multiline and ended up here https://github.com/orgs/community/discussions/25641#discussioncomment-3248571 if we try with | and everything works properly then the problem might be with > only?

Copy link
Contributor

@alinkedd alinkedd Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@awxiaoxian2020 I tried hypothesis with same condition in my test repo and it seemed to be right.

UPD
The fixes for workflows triggered by workflow_run work only if they are added to the default branch, so I could not tested them here with PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harish-sethuraman
It seems, the problem is not about block signs (|, >, etc), but rather about expression within ${{ and }} and some text around it (even if it's | or >). So today I rechecked this more readable version without expression and it works fine:

if: >
  github.event.workflow_run.event == 'pull_request' &&
  github.event.workflow_run.conclusion == 'success'

And I updated my another PR #6651 which also contains some other fixes

@rickhanlonii
Copy link
Member

@alinkedd I'd love to help here but i really just don't understand these workflows enough to review. @gaearon or @harish-sethuraman do you know?

@alinkedd
Copy link
Contributor

@rickhanlonii
I opened another PR #6651, which resolves current and some other issues

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
5 participants