github context is not accessible from step.uses
Problem
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`: [code block]` 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 [code block]` Runner and Worker's Diagnostic Logs https://github.com/myci-actions/add-deb-repo/actions/runs/469160309
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Use Environment Variables for GitHub Context in Actions
The GitHub context (`github`) is not accessible within the `uses` field of a step in GitHub Actions. This limitation arises because the `uses` field is evaluated before the job context is fully available, preventing substitution of context variables like `github.repository` and `github.sha`.
Awaiting Verification
Be the first to verify this fix
- 1
Define Environment Variables
Set the required GitHub context values as environment variables at the job level. This allows you to reference them in the `uses` field.
yamlenv: REPO: ${{ github.repository }} SHA: ${{ github.sha }} - 2
Modify Step to Use Environment Variables
Update the step that uses the `uses` field to reference the environment variables instead of the GitHub context directly.
yaml- name: Example Step uses: actions/example-action@v1 with: repository: ${{ env.REPO }} sha: ${{ env.SHA }} - 3
Test the Workflow
Run the modified workflow to ensure that the environment variables are correctly passed and the action executes as expected.
yamlRun the workflow and check the logs for the correct values being used.
Validation
Confirm that the workflow runs successfully and the logs show the expected values for the repository and SHA being used in the action. Check for any errors related to context substitution.
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep