Search code examples
environment-variablesgithub-actions

How to read environment variables in env section of github action workflow


I'm trying to set a env variable based on another env variable in a github workflow. I've tried a couple of syntax options but none seem to work

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]
  workflow_dispatch:

env:
  BASE_VERSION: 1.0.0
  FULL_VERSION: ${BASE_VERSION}-${{ github.run_number }}-${{ github.ref_name }}
jobs:
  1. The example for BASE_VERSION above just keeps ${BASE_VERSION} as a string
  2. $BASE_VERSION also just keeps $BASE_VERSION as a string
  3. ${{ env.BASE_VERSION }}-blabla just fails with syntax error

Is this doable?

The output I want is "1.0.0-1-master" for example


Solution

  • Is this doable?

    It does not seem like a supported behaviour at the moment.

    The docs on env mentions that

    variables in the env map cannot be defined in terms of other variables in the map.