You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently moved my github actions workflow to trigger on pull_request which has a different checkout behavior than on push. Then to ensure that the git repo was consistent both on push and on pr, I used the checkout action to check out the current branch.
My main issue with the default checkout on pr was that running git commands doesn't give expected output for instance git branch and git show -s --format=%B.
The issue that now occurs is that a workflow starts running on the main branch with one commit, but during the workflow, something else is merged to that branch and the next job then checks out the latest commit instead of the commit it started running with. I tried checkout out the current commit throughout the workflow instead. In python in the workflow a: return Repo(repo_root_path).active_branch.name works on push events, but in prs, results in: HEAD is a detached symbolic reference as it points to SHA. Also with ref: ${{ github.event.pull_request.head.sha }}, but works with ref: current_branch_name
Is there a way to check out a branch at a given commit consistently through a workflow both on push and on pr, for instance:
- name: Check out code
uses: actions/checkout@v4
with:
ref: branch/commit
or any other way to check out the same commit throughout a workflow while also having access to the git information?
uaing fetch-depth:0 makes no difference.
The text was updated successfully, but these errors were encountered:
I recently moved my github actions workflow to trigger on pull_request which has a different checkout behavior than on push. Then to ensure that the git repo was consistent both on push and on pr, I used the checkout action to check out the current branch.
My main issue with the default checkout on pr was that running git commands doesn't give expected output for instance
git branch
andgit show -s --format=%B
.The issue that now occurs is that a workflow starts running on the main branch with one commit, but during the workflow, something else is merged to that branch and the next job then checks out the latest commit instead of the commit it started running with. I tried checkout out the current commit throughout the workflow instead. In python in the workflow a: return Repo(repo_root_path).active_branch.name works on push events, but in prs, results in:
HEAD is a detached symbolic reference as it points to SHA
. Also with ref: ${{ github.event.pull_request.head.sha }}, but works with ref: current_branch_nameIs there a way to check out a branch at a given commit consistently through a workflow both on push and on pr, for instance:
or any other way to check out the same commit throughout a workflow while also having access to the git information?
uaing fetch-depth:0 makes no difference.
The text was updated successfully, but these errors were encountered: