-
-
Notifications
You must be signed in to change notification settings - Fork 333
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
Handle missing token on Rector CI workflow on forks #3433
Conversation
# in forks, the token is not available - so we cannot use it | ||
- | ||
if: github.event.pull_request.head.repo.full_name != github.repository | ||
uses: actions/checkout@v3 |
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 should never run, as this conditoin is never met:
if: github.repository == '__CURRENT_REPOSITORY__'
If that condition is wrong, it should be fixed.
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.
That seems overlapped, see https://github.com/rectorphp/rector-src/actions/runs/4305120316/jobs/7507111232#step:2:1
See issue on actions/checkout#298
This is workaround until we get correct fix.
Also that needed on getrector-com repo, see skipped vs working
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.
@TomasVotruba looking at other repo implementation, the if seems before steps instead of before strategy
That's seems the reason why steps was always executed
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.
These miss-steps should be prevent by the if
. How does the Google Acitons docs address this?
Maybe we have to define it on the more parent configuration?
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 don't think so, strategy
and steps
is inlined, so it is something like code:
if 1 < 0
echo "foo" <- strategy
echo "bar" <- steps
above code, "bar" is shown as not belong to if, so if we want "bar" is not executed, the if need to before echo "bar"
echo "foo"<- strategy
if 1 < 0
echo "bar"<- steps
if I understand correctly, strategy
is definition, steps
is the execution.
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.
So what is the best way to disable whole workflow with one condition?
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 think the issue is that when GitHub runs a pull_request
event it actually runs it in the base repository on a temporary branch which I think is a merge of the target and the head. Thus the github.repository == 'rectorphp/rector-src'
returns true. e.g. refs/remotes/pull/3430/merge
You need to check the repository or the head branch specifically - as has been done in the individual steps github.event.pull_request.head.repo.full_name
. I'm not sure if there's a shorter variable to get it or not
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.
@jackbentley Thanks for the tip, I'll try that 👍
Is there a way to dump all the github metadata in workflow? It might be easier to just see the values there :)
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.
@jackbentley Seem it's not the right value, the Rector workflow is skipped:
#3439
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 know if you enable debug it will output/let you download a dump of the entire github
variable. I've seen you might be able to enable it on re-run via the action page also. I think it gives you the option of "re running with debug enabled" or something like that - haven't used that way myself though
https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging
Edit: If you click the "Re-run all jobs" button there's a checkbox in the bottom left of the modal to "Enable debug logging"
* Handle missing token on Rector CI workflow * test add unused property to run rectify * update templates workflow for require token * [ci-review] Rector Rectify --------- Co-authored-by: GitHub Action <actions@github.com>
@TomasVotruba @jackbentley this is to avoid error on running on fork, see https://github.com/rectorphp/rector-src/actions/runs/4305120316/jobs/7507111232#step:2:1 on PR #3430
@jackbentley please rebase your PRs after this merged.