-
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 #6179
base: main
Are you sure you want to change the base?
Conversation
Size changes📦 Next.js Bundle Analysis for react-devThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
Who can follow this PR? |
PTAL. |
if: > | ||
${{ github.event.workflow_run.event == 'pull_request' && | ||
github.event.workflow_run.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.
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
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.
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.
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.
I actually checked and this did the trick:
How do you check this?
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.
@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?
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.
@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.
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.
@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
@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? |
@rickhanlonii |
close #5801.
The workaround is fine in zh-hans.react.dev now.