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

Composite actions have empty values for important environment variables: GITHUB_ACTION_REF and GITHUB_ACTION_REPOSITORY #2525

Closed
JamesMGreene opened this issue Apr 8, 2023 · 2 comments
Labels
bug Something isn't working composite duplicate

Comments

@JamesMGreene
Copy link

JamesMGreene commented Apr 8, 2023

Describe the bug

⚠️ For composite actions, the $GITHUB_ACTION_REF and $GITHUB_ACTION_REPOSITORY environment variables are showing up as empty for the run step execution environment.

⚠️ Similarly, but at a different point in the lifecycle, the ${{ github.action_ref }} and ${{ github.action_repository }} expression variable references are also showing up as empty at the time of expression evaluation for the run block.

To Reproduce
Steps to reproduce the behavior:

My annotations show up inlined below as one of the following:

  • # missing
  • # expected
  • # corrected

Assuming the composite action is referenced as uses: paper-spa/jekyll-build-pages@main in a workflow:

With composite action steps:

runs:
  using: composite
  steps:
    - shell: sh
      env:
        GITHUB_ACTION_REF_EXP: ${{ github.action_ref }}
        GITHUB_ACTION_REPOSITORY_EXP: ${{ github.action_repository }}
        GITHUB_ACTION_PATH_EXP: ${{ github.action_path }}
        GITHUB_ACTION_EXP: ${{ github.action }}
      run: |
        echo "github.action_ref = ${{ github.action_ref }}"
        echo "GITHUB_ACTION_REF_EXP = $GITHUB_ACTION_REF_EXP"
        echo "GITHUB_ACTION_REF = $GITHUB_ACTION_REF"
        echo "github.action_repository = ${{ github.action_repository }}"
        echo "GITHUB_ACTION_REPOSITORY_EXP = $GITHUB_ACTION_REPOSITORY_EXP"
        echo "GITHUB_ACTION_REPOSITORY = $GITHUB_ACTION_REPOSITORY"
        echo "github.action_path = ${{ github.action_path }}"
        echo "GITHUB_ACTION_PATH_EXP = $GITHUB_ACTION_PATH_EXP"
        echo "GITHUB_ACTION_PATH = $GITHUB_ACTION_PATH"          
        echo "github.action = ${{ github.action }}"
        echo "GITHUB_ACTION_EXP = $GITHUB_ACTION_EXP"
        echo "GITHUB_ACTION = $GITHUB_ACTION"

Output is:

github.action_ref =             # missing
GITHUB_ACTION_REF_EXP = main    # expected
GITHUB_ACTION_REF =             # missing
github.action_repository =                                     # missing
GITHUB_ACTION_REPOSITORY_EXP = paper-spa/jekyll-build-pages    # expected
GITHUB_ACTION_REPOSITORY =                                     # missing

### The rest all work as expected
github.action_path = /home/runner/work/_actions/paper-spa/jekyll-build-pages/main
GITHUB_ACTION_PATH_EXP = /home/runner/work/_actions/paper-spa/jekyll-build-pages/main
GITHUB_ACTION_PATH = /home/runner/work/_actions/paper-spa/jekyll-build-pages/main
github.action = __paper-spa_jekyll-build-pages
GITHUB_ACTION_EXP = __paper-spa_jekyll-build-pages
GITHUB_ACTION = __paper-spa_jekyll-build-pages

Logs show the command evaluated as:

echo "github.action_ref = "                             # missing
echo "GITHUB_ACTION_REF_EXP = $GITHUB_ACTION_REF_EXP"   # expected
echo "GITHUB_ACTION_REF = $GITHUB_ACTION_REF"           # expected
echo "github.action_repository = "                                    # missing
echo "GITHUB_ACTION_REPOSITORY_EXP = $GITHUB_ACTION_REPOSITORY_EXP"   # expected
echo "GITHUB_ACTION_REPOSITORY = $GITHUB_ACTION_REPOSITORY"           # expected

### expected - The rest all work as expected
echo "github.action_path = /home/runner/work/_actions/paper-spa/jekyll-build-pages/main" 
echo "GITHUB_ACTION_PATH_EXP = $GITHUB_ACTION_PATH_EXP"
echo "GITHUB_ACTION_PATH = $GITHUB_ACTION_PATH"
echo "github.action = __paper-spa_jekyll-build-pages"
echo "GITHUB_ACTION_EXP = $GITHUB_ACTION_EXP"
echo "GITHUB_ACTION = $GITHUB_ACTION"
shell: /usr/bin/sh -e {0}
env:
  GITHUB_ACTION_REF_EXP: main
  GITHUB_ACTION_REPOSITORY_EXP: paper-spa/jekyll-build-pages
  GITHUB_ACTION_PATH_EXP: /home/runner/work/_actions/paper-spa/jekyll-build-pages/main
  GITHUB_ACTION_EXP: __paper-spa_jekyll-build-pages

Trying to manually override those environment variables with env: also fails:

runs:
  using: composite
  steps:
    - shell: sh
      env:
        GITHUB_ACTION_REF_EXP: ${{ github.action_ref }}
        GITHUB_ACTION_REPOSITORY_EXP: ${{ github.action_repository }}
        GITHUB_ACTION_PATH_EXP: ${{ github.action_path }}
        GITHUB_ACTION_EXP: ${{ github.action }}
        # Manual overrides
        GITHUB_ACTION_REF: ${{ github.action_ref }}
        GITHUB_ACTION_REPOSITORY: ${{ github.action_repository }}
      run: |
        echo "github.action_ref = ${{ github.action_ref }}"
        echo "GITHUB_ACTION_REF_EXP = $GITHUB_ACTION_REF_EXP"
        echo "GITHUB_ACTION_REF = $GITHUB_ACTION_REF"
        echo "github.action_repository = ${{ github.action_repository }}"
        echo "GITHUB_ACTION_REPOSITORY_EXP = $GITHUB_ACTION_REPOSITORY_EXP"
        echo "GITHUB_ACTION_REPOSITORY = $GITHUB_ACTION_REPOSITORY"
        echo "github.action_path = ${{ github.action_path }}"
        echo "GITHUB_ACTION_PATH_EXP = $GITHUB_ACTION_PATH_EXP"
        echo "GITHUB_ACTION_PATH = $GITHUB_ACTION_PATH"
        echo "github.action = ${{ github.action }}"
        echo "GITHUB_ACTION_EXP = $GITHUB_ACTION_EXP"
        echo "GITHUB_ACTION = $GITHUB_ACTION"

Output is identical despite the attempt at overriding those empty environment variables:

github.action_ref =             # missing
GITHUB_ACTION_REF_EXP = main    # expected
GITHUB_ACTION_REF =             # missing
github.action_repository =                                     # missing
GITHUB_ACTION_REPOSITORY_EXP = paper-spa/jekyll-build-pages    # expected
GITHUB_ACTION_REPOSITORY =                                     # missing

### expected - The rest all work as expected
github.action_path = /home/runner/work/_actions/paper-spa/jekyll-build-pages/main
GITHUB_ACTION_PATH_EXP = /home/runner/work/_actions/paper-spa/jekyll-build-pages/main
GITHUB_ACTION_PATH = /home/runner/work/_actions/paper-spa/jekyll-build-pages/main
github.action = __paper-spa_jekyll-build-pages
GITHUB_ACTION_EXP = __paper-spa_jekyll-build-pages
GITHUB_ACTION = __paper-spa_jekyll-build-pages

Logs show the command evaluated as:

echo "github.action_ref = "                             # missing
echo "GITHUB_ACTION_REF_EXP = $GITHUB_ACTION_REF_EXP"   # expected
echo "GITHUB_ACTION_REF = $GITHUB_ACTION_REF"           # expected
echo "github.action_repository = "                                    # missing
echo "GITHUB_ACTION_REPOSITORY_EXP = $GITHUB_ACTION_REPOSITORY_EXP"   # expected
echo "GITHUB_ACTION_REPOSITORY = $GITHUB_ACTION_REPOSITORY"           # expected

### expected - The rest all work as expected
echo "github.action_path = /home/runner/work/_actions/paper-spa/jekyll-build-pages/main"
echo "GITHUB_ACTION_PATH_EXP = $GITHUB_ACTION_PATH_EXP"
echo "GITHUB_ACTION_PATH = $GITHUB_ACTION_PATH"
echo "github.action = __paper-spa_jekyll-build-pages"
echo "GITHUB_ACTION_EXP = $GITHUB_ACTION_EXP"
echo "GITHUB_ACTION = $GITHUB_ACTION"
shell: /usr/bin/sh -e {0}
env:
  GITHUB_ACTION_REF_EXP: main
  GITHUB_ACTION_REPOSITORY_EXP: paper-spa/jekyll-build-pages
  GITHUB_ACTION_PATH_EXP: /home/runner/work/_actions/paper-spa/jekyll-build-pages/main
  GITHUB_ACTION_EXP: __paper-spa_jekyll-build-pages
  GITHUB_ACTION_REF: main                                  # expected
  GITHUB_ACTION_REPOSITORY: paper-spa/jekyll-build-pages   # expected

Expected behavior
A clear and concise description of what you expected to happen.

Output expected:

github.action_ref = main      # corrected
GITHUB_ACTION_REF_EXP = main
GITHUB_ACTION_REF = main      # corrected
github.action_repository = paper-spa/jekyll-build-pages       # corrected
GITHUB_ACTION_REPOSITORY_EXP = paper-spa/jekyll-build-pages
GITHUB_ACTION_REPOSITORY = paper-spa/jekyll-build-pages       # corrected
github.action_path = /home/runner/work/_actions/paper-spa/jekyll-build-pages/main
GITHUB_ACTION_PATH_EXP = /home/runner/work/_actions/paper-spa/jekyll-build-pages/main
GITHUB_ACTION_PATH = /home/runner/work/_actions/paper-spa/jekyll-build-pages/main
github.action = __paper-spa_jekyll-build-pages
GITHUB_ACTION_EXP = __paper-spa_jekyll-build-pages
GITHUB_ACTION = __paper-spa_jekyll-build-pages

Logs should show command evaluated as:

echo "github.action_ref = main"                         # corrected
echo "GITHUB_ACTION_REF_EXP = $GITHUB_ACTION_REF_EXP"
echo "GITHUB_ACTION_REF = $GITHUB_ACTION_REF"
echo "github.action_repository = paper-spa/jekyll-build-pages"        # corrected
echo "GITHUB_ACTION_REPOSITORY_EXP = $GITHUB_ACTION_REPOSITORY_EXP"
echo "GITHUB_ACTION_REPOSITORY = $GITHUB_ACTION_REPOSITORY"

### expected - The rest all work as expected
echo "github.action_path = /home/runner/work/_actions/paper-spa/jekyll-build-pages/main" 
echo "GITHUB_ACTION_PATH_EXP = $GITHUB_ACTION_PATH_EXP"
echo "GITHUB_ACTION_PATH = $GITHUB_ACTION_PATH"
echo "github.action = __paper-spa_jekyll-build-pages"
echo "GITHUB_ACTION_EXP = $GITHUB_ACTION_EXP"
echo "GITHUB_ACTION = $GITHUB_ACTION"
shell: /usr/bin/sh -e {0}
env:
  GITHUB_ACTION_REF_EXP: main
  GITHUB_ACTION_REPOSITORY_EXP: paper-spa/jekyll-build-pages
  GITHUB_ACTION_PATH_EXP: /home/runner/work/_actions/paper-spa/jekyll-build-pages/main
  GITHUB_ACTION_EXP: __paper-spa_jekyll-build-pages

Runner Version and Platform

Version of your runner?

  • Using ubuntu-latest on GitHub.com 🤷🏻‍♂️

OS of the machine running the runner? OSX/Windows/Linux/...

  • Ubuntu Linux 🐧

What's not working?

Please include error messages and screenshots.

N/A

Job Log Output

If applicable, include the relevant part of the job / step log output here. All sensitive information should already be masked out, but please double-check before pasting here.

Inlined above.

Runner and Worker's Diagnostic Logs

If applicable, add relevant diagnostic log information. Logs are located in the runner's _diag folder. The runner logs are prefixed with Runner_ and the worker logs are prefixed with Worker_. Each job run correlates to a worker log. All sensitive information should already be masked out, but please double-check before pasting here.

N/A?

@JamesMGreene JamesMGreene added bug Something isn't working composite labels Apr 8, 2023
@JamesMGreene JamesMGreene changed the title Composite actions have empty values for important environment variables: GITHUB_ACTION_REF and GITHUB_ACTION_PATH Composite actions have empty values for important environment variables: GITHUB_ACTION_REF and GITHUB_ACTION_REPOSITORY Apr 13, 2023
@JamesMGreene
Copy link
Author

Duplicate of #2473 😅

@ruvceskistefan
Copy link
Contributor

Hey @JamesMGreene,
Since this is the duplicate issue of #2473, I'll add a Duplicate label for tracking and close this one.

@JamesMGreene JamesMGreene closed this as not planned Won't fix, can't repro, duplicate, stale May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working composite duplicate
Projects
None yet
Development

No branches or pull requests

2 participants