checkout@v2 not getting recent commits
See original GitHub issueAssume a Github action with two Jobs - job1 & job2
In job1: Use checkout action to checkout the repo, update any file in the repo, commit and push the changes.
In job2:
Again use checkout action. The repo doesn’t contain the commit made in job1.
Here is a replicable sample:
jobs:
update-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: |
// update file1.txt
git add file1.txt
git config --local user.email "github-actions@users.noreply.github.com"
git config --local user.name "github-actions"
git commit -m "updated file1"
git push
deploy:
needs: update-version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: cat publish file
run: |
# the changes made in job1 are not reflected here
cat file1.txt
Issue Analytics
- State:
- Created 3 years ago
- Reactions:32
- Comments:15
Top Results From Across the Web
git - How to get back to the latest commit after checking out a ...
If you know the commit you want to return to is the head of some branch, or is tagged, then you can just...
Read more >Github Actions | Commitsar - aevea
When using JIRA make sure to set actions/checkout@v2 to pull from the pull_request HEAD. Github uses a single merge commit by default which...
Read more >12. Getting older versions - Git How To
The checkout command can copy any snapshot from the repo to the working directory. 01 Getting hashes for the previous versions. Run: git...
Read more >2.3 Git Basics - Viewing the Commit History
You can also limit the number of log entries displayed, such as using -2 to show only the last two entries. $ git...
Read more >7 Github Actions Tricks I Wish I Knew Before I Started
#1: How to Use Github Action Triggers; #2: Reusable Workflows with ... You might not yet be confident enough in the process to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I ran into the same problem and came across this issue. But could figure out a solution within the documentation.
This means by default the commit where the workflow was triggered will be taken. You can specify the master branch with
ref: 'master'
As @sebastian-muthwill mentions, you can use the
ref
attribute to point to a specific branch. This way subsequent jobs always pull the latest code from that branch, and not from the revision that started the workflow.@mugbug I think
fetch-depth: 0
is your friend.Here’s a full example that works for me when running multiple jobs that each generate a change-log file (i.e. modify the branch)
@adnan-kamili Does this solve your issue?