(Optionally) Ref to a branch and if it doesn't exist, use default
See original GitHub issueHey!
Is there a way to get a ref
to work like an optional OR? For example:
// GITHUB_HEAD_REF being the name of the branch if my google-foo didn't fail me
ref: ${GITHUB_HEAD_REF} || master
My use-case: I have multiple repos that depend on each other sometimes. If they do, they all share the same branch name for a feature (e.g feature/add-tests
). I want to pull the repos with those branches when they exist, but if they don’t (as it’s not always necessary to change code in all repos), it’ll pull master
.
Thanks!
Issue Analytics
- State:
- Created 2 years ago
- Reactions:19
- Comments:6
Top Results From Across the Web
Git change branch when file of same name is present
The new behavior: if there is no local branch and multiple remote candidates, just die() and don't try reverting file whether it exists...
Read more >Default branch - GitLab Docs
When you create a new project, GitLab creates a default branch in the repository. A default branch has special configuration options not shared...
Read more >git-switch Documentation - Git
If the branch exists in multiple remotes and one of them is named by the checkout.defaultRemote configuration variable, we'll use that one for...
Read more >git-push - Update remote refs along with associated objects
When the command line does not specify where to push with the <repository> argument, branch.*.remote configuration for the current branch is consulted to ......
Read more >torch.hub — PyTorch 1.13 documentation
github (str) – a string with format <repo_owner/repo_name[:ref]> with an optional ref (a tag or a branch). If ref is not specified, the...
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
@vinayakkulkarni here is a pattern that I have been using.
https://github.com/hse-project/hse/blob/master/.github/workflows/builds.yaml#L99
Determine if branch exists using
git ls-remote
.I have a similar use case and was hoping actions/checkout would have something like a
fallback-to-default
boolean option. For the longest time I’ve been copy/pasting some ugly bash I wrote, but I recently got tired of it and wrote a composite action. I’ve included it below. The options you see are all the ones I need for my use case, so I didn’t bother adding anything else. Feel free to modify it. Hope you find it useful.