Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 3
Message 1 of 3

ENV vars are not expanded, causing DRY violations

Solved! Go to Solution.

Problem:

 

The Jobs -> Action -> ENV specification does not expand existing ENVs.

 

name: Go
on: [push]
jobs:

  build:
    name: Build
    runs-on: ubuntu-latest
    strategy:
      fail-fast: true
    env:
      CODE: ~/go/src/github.com/${GITHUB_REPOSITORY}

    - name: Print Code
      run: echo ${CODE}

 

Expected:

 

    /home/runner/go/src/github.com/eduncan911/github-actions

 

Actual Results:

 

    ~/go/src/github.com/${GITHUB_REPOSITORY}

 

It does not expand the `~` tilda, nor the `${GITHUB_REPOSITORY}` environment variables.

 

2 Replies
Solution
GitHub Staff
Message 2 of 3

Re: ENV vars are not expanded, causing DRY violations

No, that's not expanded since the YAML is not evaluated in the context of the bourne shell.  You can use the YAML variable expansion, though:

 

name: Go
on: [push]
jobs:

  build:
    name: Build
    runs-on: ubuntu-latest
    strategy:
      fail-fast: true
    env:
      CODE: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}

    - name: Print Code
      run: echo ${CODE}

 

Copilot Lvl 3
Message 3 of 3

Re: ENV vars are not expanded, causing DRY violations

Nice! I'll give that a shot and will report back.