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

Issue 1234: Support GITHUB_ACTION_PATH in composite action 'uses' #1684

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ricCap
Copy link

@ricCap ricCap commented Feb 13, 2022

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

@nyarly
Copy link

nyarly commented Feb 14, 2022

@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?

@ricCap
Copy link
Author

ricCap commented Feb 15, 2022

@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 }}

@ricCap
Copy link
Author

ricCap commented Mar 1, 2022

@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

@nyarly
Copy link

nyarly commented Mar 3, 2022

@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

@ricCap ricCap marked this pull request as ready for review March 8, 2022 20:13
@ricCap ricCap requested a review from a team as a code owner March 8, 2022 20:13
@ricCap
Copy link
Author

ricCap commented Mar 22, 2022

Any chance I can get some comments on this PR? @TingluoHuang @thboop @fhammerl? Thanks

@ricCap ricCap closed this Apr 9, 2022
@ricCap
Copy link
Author

ricCap commented Apr 9, 2022

Hoping to get some feedback on this

@ricCap ricCap reopened this Apr 9, 2022
@nyarly
Copy link

nyarly commented May 3, 2022

@DawnGKoz904 @TingluoHuang @thboop @fhammerl - could you approve the workflow run on this PR? I'm eager to see this feature merged

@antdking
Copy link

antdking commented Jul 4, 2022

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!

@byF
Copy link

byF commented Aug 12, 2022

@nyarly What's blocking this?

@nyarly
Copy link

nyarly commented Aug 12, 2022

@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

@byF
Copy link

byF commented Aug 12, 2022 via email

@JoakimSM
Copy link

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]

@uittorio
Copy link

Hi, I would like to help to get this merged. I've checked the changes but I couldn't see any tests @ricCap.

@neilime
Copy link

neilime commented Aug 23, 2023

Any chance to have this PR merged?

@nyarly
Copy link

nyarly commented Aug 23, 2023

@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.

tonisojandu-sympower added a commit to sympower/sympower-actions that referenced this pull request Oct 24, 2023
This is to avoid self-reference release before the version commit exists and is tagged.
Self-reference would cause a Renovate loop in Sympower Actions.

Relative references are not supported yet:
actions/runner#1348
actions/runner#1684

This PR has been on the shelf since February.  [Comment](actions/runner#1684 (comment)) from @nyarly from August suggests that this feature could compromise the feature set that is reserved for Enterprise users, so there is no confidence that it will be merged.

Tested the changes here:
https://github.com/sympower/msa-observability/actions/runs/6626012294
https://github.com/sympower/msa-observability/actions/runs/6626046945
@neilime
Copy link

neilime commented Oct 29, 2023

Hi, I hope Github Staff is aware of this need, can we have some feedback on it please?

@fredleger
Copy link

@TingluoHuang we need this one also. Any chance this could be merged (1 year old PR)

@neilime
Copy link

neilime commented Jun 14, 2024

Hi @TingluoHuang any news on this topic? We still need this one. Thanks

@neilime
Copy link

neilime commented Sep 26, 2024

Hi, any chance to have some news for this PR?

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

Successfully merging this pull request may close these issues.

Local composite actions always relative to top level repository
8 participants