FG
☁️ Cloud & DevOpsMicrosoft

github context is not accessible from step.uses

Freshabout 21 hours ago
Mar 14, 20260 views
Confidence Score75%
75%

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

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Use Environment Variables for GitHub Context in Actions

Medium Risk

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

    yaml
    env:
      REPO: ${{ github.repository }}
      SHA: ${{ github.sha }}
  2. 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. 3

    Test the Workflow

    Run the modified workflow to ensure that the environment variables are correctly passed and the action executes as expected.

    yaml
    Run 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

AC

Alex Chen

2450 rep

Tags

github-actionsci-cdrunnerbugactions-feature