-
Notifications
You must be signed in to change notification settings - Fork 6
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
The shared workflows reference actions as though they are external rather than in the same repository #4
Comments
So I've done some research on this and it's.. bleak. The checkout for the shared workflow does not happen on the runner like I thought (like it does for actions), it seems retrieving the shared workflow happens internal to the orchestration around workflows, before a runner is ever acquired, which does make sense. But it means the workflow(s) being executed are not on the runner. In addition to that, I've dumped everything I can in such a job and as far a shared workflow "knows" from its runtime environment, its event was the event that triggered the calling workflow, which also kind of makes sense but it means there's no info at all that we could use to figure out which commit's version of the shared workflow was invoked. As far as I can tell, this leaves us in the unenviable position of hardcoding the commit hashes of the local actions (or hardcoding a commit for a checkout and referencing the actions locally, same difference), which presents some of the same issues as #10 , but with additional complications as it relates to making changes in this repo. |
Maybe we need a 'build' script which creates copies of the files with |
I've come up with a possible implementation strategy of @felixfontein 's idea above, whereby we come up with a script that can replace the references, hereafter referred to as the "script" and then leveraging github workflows to perform the changes. In my mind this looks like so: The script
Workflow:
|
a couple of afterthoughts on the above, regarding running the reference updater on all branches:
|
If there's a tag pointing to it, it's not orphaned :) If you push a tag to a commit that's not contained in any branch of the repo, you end up with that tagged commit in the repository. So it should work fine without creating a branch. Besides that, you plan sounds good! (About rebasing while pulling: I've |
Well that sounds good, I can't tell if you know for certain it works or just strongly suspect.. but I do hope so, it would simplify it a bit.
🙌😀
I do the same! I added it explicitly in the example for those who don't, or those who do and forget not everyone does ;) |
I think I did that at some point in the past. I don't remember that clearly anymore, it has been a longer time ago (more than a year). |
Any updates on this? I'm trying to do something very similar. I have a repo for creating reusable workflows and actions; in my workflow, I reference my composite actions with |
For example
ansible-community/github-docs-build/actions/ansible-docs-build-init@main
This works but is problematic for several reasons:
main
pull_request_target
event, because during development and testing the refs all need to be changed to the PR branch, and then changed once again before mergingActions can be referenced from the local filesystem, for example the above would change to
./actions/ansible-docs-build-init
. The possible challenge to this, is that typically, you must do a checkout on the runner first to ensure the files actually exist. In most repositories, this is pretty straightforward because you're already doing a checkout anyway.With these shared workflows, a checkout is running in context of the calling repo, not the workflow's repo. I am not sure if there's a way that we can infer from within the workflow, which commit of the shared workflow itself has been referenced. If we can do that, we can also do a checkout of the repo and get the actions that way.
What would be really ideal, is to re-use the checkout that already occurred to get the workflow in the first place. Much like actions, shared workflows are automatically retrieved with a git clone/checkout by the runner system, so the files are somewhere. Composite actions have a variable they can access that gives the filesystem location of the action (so that files in the action can be referenced). If a similar variable exists for shared workflows that would be the ideal way to handle this. I have not seen any documentation that suggests that variable exists though.
In the reusing workflows page there is an example that references a local action:
The interesting thing about this example is that is clearly does not have a checkout step, implying that local action references will "just work" but I have not tried this yet. The example is not meant to demonstrate local action referencing though, so it's entirely possible that this is a non-working example.
The text was updated successfully, but these errors were encountered: