-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(Optionally) Ref to a branch and if it doesn't exist, use default #512
Comments
Thinking about this further, I guess I can just run a bash command before this to define the branch name and export a variable to use in the checkout action. But if I have multiple repos this would become a lot of copy paste code for each repo 😄 I'm just wondering wether there's built-in way, or maybe a potential feature? |
Looking for the same feature here! Any updates on this? |
Just hit this, this would be so handy. Now I'm thinking I'll also take a route of checking if the branch is available in the other repo. |
Is there a workaround for this? |
@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 |
I have a similar use case and was hoping actions/checkout would have something like a
|
For anyone looking for other simple options, you can use steps:
- name: Try checkout on first branch
uses: actions/checkout@v4
id: bad-checkout
continue-on-error: true
with:
repository: actions/checkout
ref: some-bad-branch
# If the first checkout fails, we checkout the `main` branch by default
- name: Fallback to main branch
if: steps.bad-checkout.outcome == 'failure'
uses: actions/checkout@v4
with:
repository: actions/checkout
ref: main |
Hey!
Is there a way to get a
ref
to work like an optional OR? For example: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 pullmaster
.Thanks!
The text was updated successfully, but these errors were encountered: