runner: github context is not accessible from step.uses
Describe the bug
It is not possible to use github
context in jobs.<job_id>.steps[*].uses
.
To Reproduce
create workflow which uses github
context within uses
:
name: ci
on: [push, pull_request]
jobs:
my_job:
runs-on: ubuntu-latest
steps:
- name: this repo action
uses: ${{ github.repository }}@${{ github.sha }}
Expected behavior
github.repository
and github.sha
are substituted with correspoonding values.
Runner Version and Platform
public runner
What’s not working?
github
context variable substitution
Job Log Output
The workflow is not valid. .github/workflows/ci.yml (Line: 17, Col: 15): Unrecognized named-value: 'github'. Located at position 1 within expression: github.repository
Runner and Worker’s Diagnostic Logs
https://github.com/myci-actions/add-deb-repo/actions/runs/469160309
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 8
- Comments: 21 (5 by maintainers)
Commits related to this issue
- Use hardcoded version of `run-workflow` action Currently branch name used in action address cannot be substituted with ${{ github.event.inputs.ref }} variable, because `github` context is not availib... — committed to keep-network/ci by michalinacienciala 3 years ago
- Use hardcoded version of `run-workflow` action Currently branch name used in action address cannot be substituted with ${{ github.event.inputs.ref }} variable, because `github` context is not availib... — committed to keep-network/ci by michalinacienciala 3 years ago
- ci(pip-compile): run two jobs cannot use matrix to run actions dynamically use action See: https://github.com/actions/runner/issues/895#issuecomment-825297950 — committed to coatl-dev/actions by thecesrom 9 months ago
- ci(pip-compile): run two jobs (#8) cannot use matrix to run actions dynamically use action See: https://github.com/actions/runner/issues/895#issuecomment-825297950 — committed to coatl-dev/actions by thecesrom 9 months ago
We don’t support expression in those place, you need to checkout the repo to use local action.
In addition to the list of legit use cases pointed out above. One could structure a repo containing both reusable workflows and actions, and might want to guarantee the version of the actions used remains in sync with the reusable workflow, having access to
github.job_workflow_sha
could be pretty useful.Lets say I have two repos. Repo A has a workflow that calls Composite Action 1 in Repo B. Composite Action 1 calls Composite Action 2 in Repo B.
The lack of availability of the
github
context object means that a composite action cannot use another composite action unless the branch is hard coded.In Composite Action 1, I want to have the following:
However, I can’t because the
.
resolves to the workspace of the calling workflow (which defaults to the root of the repo, Repo A), not the root of the repo where the composite actions are located, Repo B.My first instinct is to do this:
However, the
github
object is not available. I also can’t do this:Instead, I have to hard code the reference to the nested composite action, which greatly complicates the development workflow for working on these shared actions.
We want the YAML file readable at some level, so we don’t open expressions for every part of the YAML file.
You can make a feature request at https://github.community/c/code-to-cloud/github-actions/41
The runner repo might not be a good place for this kind of question, it doesn’t understand YAML at all, the service parses the YAML and validates against a defined schema. 😄
If we have a checkout action that sets a path relative to
GITHUB_WORKSPACE
and then want to call a custom action, is there a way to do this?I’ve tried various things and haven’t found a method that works.
I’ve figured out a workaround using a composite action that generates and runs another composite action to call the desired action dynamically 😅 … Give
jenseng/dynamic-uses@v1
a spin (or feel free to borrow/fork/adapt its action.yml)Given a step like so:
If you want your
uses
to be dynamic you can do:We want to have a security check of you containers implemented for every PR that is created.
For that it is crucial to build the container in one job, push it into the registry and then pull and run some command in it.
How can we achieve this when we cannot use the variables in this context?
We are facing the exact same issue when trying to build unified actions & workflows for hundreds of repos within our orga. Having the github context available in
steps.uses
would simplify a lot in our setupThis is exactly our use case, it’s disappointing it isn’t supported
If you try access a sibling action that you want to have at the same ref as the action being executed you need that expansion too.
😞
@chrispat from product
This looks to me as a pretty weak argumentation.
I find forums pretty bad place for feature requests, as the post on forums quickly gets lost and nobody follows up on those. There should be a bug tracker for that! This is why I opened it here. I have no idea which part of the software is responsible for yaml parsing, could you forward this to the right team/software component?