Martin Frost

Refer to another part of a YAML document in GitHub Actions

Published:

Here is a sample github action that shows how to refer to another part of the YAML file. It sets a Python version to use in an env block, and then refers to that version in the actions/setup-python action.

name: sample workflow

on: push

env:
  PYTHON_VERSION: "3.12"

jobs:
  steps:
    - uses: actions/setup-python@v4
      with:
        python-version: ${{ env.PYTHON_VERSION }}
    - run: python --version
      shell: bash