ENV vars are not expanded, causing DRY violations

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.

4 Likes

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}
2 Likes

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