Issue 1234: Support GITHUB_ACTION_PATH in composite action 'uses'
As this is my first contribution to the runner, I'd love to collect some feedback on my attempt to fix #1348 . Please let me know if this type of solution (substituting the value at that location) is virtually acceptable (with some refactoring) and if so, what type of tests I should add.
This PR substitutes the string ${GITHUB_ACTION_PATH} with the specific value, solving the use case of the ticket, and also allowing to use actions with the syntax uses:my-org/my-action/.github/actions/my-action@v1, where my-action is a composite action that uses other actions contained in its subfolders. A full example (tested against the code of this PR can be found here, test workflow.
- github/.actions/my-action
- my-sub-action
// workflow
- uses: actions/checkout@v2
- uses: ./.github/actions/my-action
// or also
- uses: my-org/my-repo/.github/actions/my-sub-action@main
// my action
...
- uses: ${GITHUB_ACTION_PATH}/my-sub-action
Ensuring that I don't break the existing tests: https://github.com/ricCap/runner/actions/runs/1836874946
@ricCap I'm not 100% this would solve my use case - how is $GITHUB_ACTION_PATH computed? Note that, because I want to use actions from a private repo and our org can't justify an enterprise account, we can't at present refer to the actions directly; we need to check them out during the run. Second, the path is required for me to find e.g. script files, not just uses: paths - can that variable be used outside of uses contexts? env: for instance?
@nyarly thank you very much for the feedback. Let me add some context:
The GITHUB_ACTION_PATH or ${{ github.action_path }} is a variable that exists for composite actions, available in the github context, and that specifies the location of the action documented here.
| github.action_path | string | The path where an action is located. This property is only supported in composite actions. You can use this path to access files located in the same repository as the action. |
|---|
For script files, you can already call your script (in myAction)using:
runs: ${GITHUB_ACTION_PATH}/myScript.sh
runs: ${{ github.action_path }/myScript.sh #same value
assuming you have a folder structure like
- myAction
- myScript.sh
Note the GITHUB_ACTION_PATH, or equilìvalent ${{ github.action_path }}, is already populated correctly (and is part of the official documentation).
The reason for this PR is that the uses field does not have access to contexts such as "github", "env",...
Not allowed now uses: ${{ github.action_path }}/my-sub-action
This PR tries to solve two problems:
- for public/internal repositories, you can now check out a composite action using the syntax
uses:yourOrg/yourRepo/your-action@v2, which will check it out in a particular location (default $YOUR_RUNNER_LOCATION/_work/actions/...), and use other actions that are contained in sub-folders of that action, allowing people to package composite actions together under the same parent action. - for private repositories (and this I assumed covers your use case), you can now checkout your actions repository as usual, and you can reference using a relative path other actions that live alongside your "main" composite action. After ${GITHUB_ACTION_PATH}, you can have any relative path, targeting all actions within your repo (and I assume it works also for all that are in your GITHUB_WORKSPACE), using a relative path to them
uses:${GITHUB_ACTION_PATH}/../../my_action_in_another_folder.
Glad to add more details if it is still unclear. Thanks
Short answer:
- how is $GITHUB_ACTION_PATH computed? documented here.
- the path is required for me to find e.g. script files, not just uses: paths - can that variable be used outside of uses contexts? env: for instance? yes, just use the populated env variable ${env.GITHUB_ATION_PATH} or the one coming from the context context ${{ github.action_path }}
@TingluoHuang @thboop any chance I can get some feedback on this PR? This is a feature that we would really love to use @nyarly was my answer/this PR what you were looking for?
Thanks all
@ricCap That looks like exactly what I need. I just confirmed: we have many lines like
uses: the-directory-you-have-to-check-out-to/sub-action-one.yaml
so being able to use ${github.action_path} would be 100% an improvement
Any chance I can get some comments on this PR? @TingluoHuang @thboop @fhammerl? Thanks
Hoping to get some feedback on this
@DawnGKoz904 @TingluoHuang @thboop @fhammerl - could you approve the workflow run on this PR? I'm eager to see this feature merged
Without this, we need to effectively bypass the security controls around allow-lists for acceptable Actions within a repo/organisation, relying on "generating" an Action on the fly, then invoking it locally.
Please can we get some attention on making Composite Actions more usable!
@nyarly What's blocking this?
@byF I don't know why you're asking me - I reported a related issue. I can't approve the CI run or anything. That'd be @DawnGKoz904 @TingluoHuang @thboop @fhammerl, maybe
@nyarly Sorry man, I thought you were part of this effort on Github side. The joy of doing OSS :)
On Sat, Aug 13, 2022, 00:24 Judson Lester @.***> wrote:
@byF https://github.com/byF I don't know why you're asking me - I reported a related issue. I can't approve the CI run or anything. That'd be @DawnGKoz904 https://github.com/DawnGKoz904 @TingluoHuang https://github.com/TingluoHuang @thboop https://github.com/thboop @fhammerl https://github.com/fhammerl, maybe
— Reply to this email directly, view it olucie_kubeckovan GitHub https://github.com/actions/runner/pull/1684#issuecomment-1213562901, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEQWKWPOZCNXEMBFAC7RLLVY3FLNANCNFSM5OI7RE7A . You are receiving this because you were mentioned.Message ID: @.***>
Landed here looking for a solution to the uses:${GITHUB_ACTION_PATH} problem. I eventually came up with a workaround for my project that might help someone (while we wait for some eyes on this)
Copy your internal actions into the github workspace. something like: run: cp -r $GITHUB_ACTION_PATH/.github/actions ./actions. Then you should be able to do: uses: ./actions/[your action]
Hi, I would like to help to get this merged. I've checked the changes but I couldn't see any tests @ricCap.
Any chance to have this PR merged?
@TingluoHuang, as Github Staff, could you comment on whether this PR has a chance of being merged? It seems like this feature might effectively be a way for regular GHA users to get features that have been reserved for Enterprise.
Will that prevent the runner team from merging this PR? If so, would you close it with a comment to that effect? The potential for this feature has impacted my planning a number of times now.
Hi, I hope Github Staff is aware of this need, can we have some feedback on it please?
@TingluoHuang we need this one also. Any chance this could be merged (1 year old PR)
Hi @TingluoHuang any news on this topic? We still need this one. Thanks