I have a js file like this
// test.js
exec(`git show master:src/path/to/my.json`, (err, stdout, stderr) => {
if (err) {
console.log('failed', stderr);
return;
}
....
}
and a script cmd
// package.json
scripts: {
doIt: "node test.js"
}
Executing this in github action
...
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0
- name: DoIt
run: yarn doIt
...
but getting error:
failed fatal: invalid object name master
Here is the github action output
* [new branch] master -> origin/master
CodePudding user response:
Considering the default naming branch has changed on GitHub, from master to main, check the one for the repository accessed by your GitHub action.
If the default branch is main, master would not exist.
Adding fetch-depth:0 is a good idea in order to fetch the all history (therefore all the branches), as seen in issue 438
But a workaround is: git show origin/master:src/path/to/my.json, as suggested in teh comments will work even if the master branch was not properly updated.
