Skip to content
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

Allow running the reusable workflow from the same branch #932

Closed
TWiStErRob opened this issue Oct 31, 2021 · 8 comments
Closed

Allow running the reusable workflow from the same branch #932

TWiStErRob opened this issue Oct 31, 2021 · 8 comments
Labels
enhancement New feature or request

Comments

@TWiStErRob
Copy link

TWiStErRob commented Oct 31, 2021

Note: this repo is my best guess for the issue, as it seems workflow_call is not implemented in this org?! Please move it if it's not appropriate.

Describe the enhancement
Allow using the same branch for workflow_call.

Fully-qualified / cross-repo reusability is awesome, but the base case of reusing locally is missing. To develop/change a workflow_call I need to update all the usages to test it, imagine the same in programming and method calls 😒.

At the minimum please add this to https://docs.github.com/en/actions/learn-github-actions/reusing-workflows#limitations

Code snippet
Right now we have to use a specific ref (archive):

jobs:
  caller:
    uses: org/repo/.github/workflows/file.yml@ref

For development and stability, it would be best to allow non-qualified usage, for example:

uses: org/repo/.github/workflows/file.yml

at this point the workflow from the same branch would be used.

SO user makes a good argument here: https://stackoverflow.com/a/69676592/253468

This would only work if it's the same repo, so maybe it could be even simpler as

uses: ./.github/workflows/file.yml

or just

uses: file.yml

Additional information
https://stackoverflow.com/q/69532525/253468
https://stackoverflow.com/q/69500491/253468

@TWiStErRob TWiStErRob added the enhancement New feature or request label Oct 31, 2021
TWiStErRob added a commit to TWiStErRob/net.twisterrob.healthcheck that referenced this issue Oct 31, 2021
TWiStErRob added a commit to TWiStErRob/net.twisterrob.healthcheck that referenced this issue Oct 31, 2021
@sam-myers
Copy link

This is now available!

Taken from source:

jobs:
  call-workflow-in-local-repo:
    uses: ./.github/workflows/workflow-2.yml

@TWiStErRob
Copy link
Author

Thanks for the heads up!
Confirmed: TWiStErRob/net.twisterrob.healthcheck#28

GitHub is really unresponsive in this repo :( closing this now in hopes that less open issues will yield more responses. 🤞

@marc-hb
Copy link

marc-hb commented Nov 14, 2023

Unfortunately, it's not possible to use a different branch in the same repo:

uses: ./.github/workflows/local-workflow@different-branch

invalid value workflow reference: cannot specify version when calling local workflows

Trying to "cheat" and refer to the current repo as if it were a different one results in a super cryptic error:

uses: myself/.github/workflows/local-workflow.yml@different-branch

The workflow is not valid. .github/workflows/caller.yml: Unexpected value 'uses'

Funnily enough, adding a repo indirection that uses back the starting repo shows the same cryptic error.

@TWiStErRob
Copy link
Author

TWiStErRob commented Nov 14, 2023

Just to rule it out (based on your code block examples): did you refer to myself as org/repo or just repo?

@marc-hb
Copy link

marc-hb commented Nov 14, 2023

org/repo, otherwise repo gives the expected:

invalid value workflow reference: references to workflows must be 
prefixed with format 'owner/repository/' or './' 

It's only when all the values are correct that I get the cryptic error message. If I make a typo in anything, then I get a useful error message like for instance should be either a valid branch, tag, or commit

What really baffles me is this in your description:

Right now we have to use a specific ref
uses: org/repo/.github/workflows/file.yml@ref

So when implementing local references, GitHub (accidentally?) broke explicit self-references? Are you positive this used to work?

@marc-hb
Copy link

marc-hb commented Nov 14, 2023

OK, now I'm getting the same cryptic error even after moving the called workflows to a different repository. Maybe it's just an error propagation issue when nesting workflows.

@marc-hb
Copy link

marc-hb commented Nov 15, 2023

Trying to "cheat" and refer to the current repo as if it were a different one results in a super cryptic error:
Unexpected value 'uses'

My bad, it is possible to do this. I had runs-on: self-hosted before uses:, that was the actual problem. I really wish GitHub would communicate that better and before parsing the uses: parameter; that really threw me off!

Thanks for questioning me, that really helped.

Note the following is still not possible; no confusion about that. That error stands:

uses: ./.github/workflows/local-workflow@different-branch

invalid value workflow reference: cannot specify version when calling local workflows

So if you want to store your called workflows in a different branch of the same repo, then you must hardcode your entire, own repo name in the calling file. It definitely lacks flexibility and it's not clear why but I'll live with that.

@TWiStErRob
Copy link
Author

@marc-hb Glad you figured it out.

What really baffles me is this in your description

I actually don't remember if it worked as my goal was to use it from "current" and not a specific one. I just copied what was available at the time. I updated OP with an archive link, so you can see my context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants