checkout: bad revision 'master' when using Lerna
I am trying to use the lerna run build --since master
command in an action to only build packages that have changed in the branch. Lerna is running this git command to do that: git diff --name-only master -- packages/<package name>
. That results in this error: lerna ERR! fatal: bad revision 'master'
.
I’ve tried many different options and commands from the README in this project but nothing seems to work. I’ve set the fetch depth to 0 to fetch all history and I’ve tried manually specifying a git command like so:
- uses: actions/checkout@v2
- run: |
git fetch --prune --unshallow origin master
Nothing seems to make master available for Lerna to compare against. Any help would be appreciated.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 13
- Comments: 15 (4 by maintainers)
Commits related to this issue
- chore: use actions/checkout@v2 and pass ref Refs: https://github.com/actions/checkout/issues/118#issuecomment-570441877 — committed to trivikr/aws-sdk-js-v3 by trivikr 4 years ago
- fix: add origin/ in lerna --since Refs: https://github.com/actions/checkout/issues/118#issuecomment-595438258 — committed to trivikr/aws-sdk-js-v3 by trivikr 4 years ago
- fix: explicitly add git fetch in checkout action Refs: https://github.com/actions/checkout/issues/118#issuecomment-595438258 — committed to trivikr/aws-sdk-js-v3 by trivikr 4 years ago
- chore: test https://github.com/actions/checkout/issues/118#issuecomment-595438258 — committed to donmahallem/js-libs by donmahallem 3 years ago
So for everyone who lands here via google. My workflow looks like:
I only need the
origin/master
. If you need all branches use this run command (via docs)I did manage to get this working by doing a few things (which might not all be necessary):
fetch-depth: 0
to the checkout actiongit fetch --prune
to the checkout actionlerna run build --since origin/master
That seems to do the trick so this issue can probably be closed, however it would be nice if this were in the docs. I’d be happy to submit a PR if this is something others think should be included.
This worked too:
This looked cleaner but https://github.com/actions/checkout/issues/118#issuecomment-595438258 looks more resource efficient.
I think mentioning that in the docs is helpful but it doesn’t really solve the problem. You could add an option to the checkout action to always fetch
master
in addition to the current ref or make it soref
takes an array of things to check out.It would also be nice to add an example in the documentation that shows how to use Lerna with GitHub Actions. It’s a very commonly used tool with monorepos. I’d be happy to help with any of this work.
What happens if you use
refs/remotes/origin/master
as the argument to--since
?As far as I can tell, reading the source of this action, the only explicit symbolic ref available in a branch build will be the branch itself, not the default branch (usually
master
). Using the fully-qualifiedrefs/...
path …might work?If this is running on a branch/PR you can’t really set
ref: master
because you want to checkout the branch notmaster
. So there is no local reference tomaster
even if you rungit fetch
.@iansu is right. It seems like I have to use
origin/
ingit log
or fetchorigin/master
.