Last successful CI run on PR branch
sdjnes opened this issue · 2 comments
Hello. I wanted to use this action to set the base and head SHA for a PR where the head is the head of the branch for the PR and the base is the last successful CI run in that PR. If there is no CI run for that PR, it should use the branching point between the PR branch and the PR target (usually main, but maybe not always), as the base for nx affected.
The wording in the README is a little bit ambigious as to whether this action can achieve it:
This action enables you to find:
Commit SHA from which PR originated (in the case of pull_request)
Commit SHA of the last successful CI run
Digging into the code, I believe I can't fulfill my above requirements.
If the action is run with lastSuccessfulEvent
set to pull_request
(not pull-request
as documented, I believe this is also incorrect as the GitHub API event is pull_request
snake_cased), the branch
for the call to the GitHub API is set to mainBranchName
:
- Relevant function line:
nx-set-shas/find-successful-workflow.js
Line 101 in a89d5d8
- Function call:
nx-set-shas/find-successful-workflow.js
Line 33 in a89d5d8
Therefore, the CI runs for the PR branch will not be returned, only those for mainBranchName
.
If the action is run with the lastSuccessfulEvent
set to push
(as per the other side of the ternery operator), no CI runs for the PR branch will be returned as they are all tagged as pull_request
events since my action is triggered by pull requests.
I ended up tweaking and stripping back the code of this action to use as a local action in my repo to fulfill what I need. It can be found here. But it would be great to know if I've just misconfigured this action and it's actually possible to compare CI runs of the PR branch.
This action is not intended to be used for detecting the last successful build on a PR.
You can always specify mainBranchName
to point to the branch but that obviously doesn't scale.
Do you want to create a PR with your changes?
I am closing this as stale.