You can set env vars available across the entire workflow e.g. like in this post.
(From solution on linked post)
name: Git Pull Request Workflow
on:
workflow_dispatch:
pull_request:
branches:
- master
env:
one: 1
two: zwei
three: tres
jobs:
first-job:
runs-on: ubuntu-latest
steps:
- run: |
echo "${{ env.one }}"
echo "${{ env.two }}"
echo "${{ env.three }}"
I have a workflow that uses a matrix strategy and I have to update it in each job if I ever change it. I tried to make it a global variable like above:
name: Model Multipliers
on:
push:
branches:
- main
env:
FRUIT: ["Apple", "Pear", "Banana", "Orange"]
jobs:
ssql-get:
runs-on: ubuntu-latest
strategy:
matrix:
FRUIT: ${{ env.FRUIT }}
name: Get data
steps:
- name: Checkout cum-rev repo
But this gives error:
The workflow is not valid. .github/workflows/main.yml (Line: 12, Col: 9): A sequence was not expected .github/workflows/main.yml (Line: 19, Col: 15): Unrecognized named-value: 'env'. Located at position 1 within expression: env.FRUIT
Is what I'm trying to do possible by any other means?
env: FRUIT: [Apple, Pear, Banana, Orange]
then further down when I reference I havematrix: FRUIT: ${{ env.FRUITS }}
then when I run the workflow I get error "The workflow is not valid. .github/workflows/main.yml (Line: 9, Col: 10): A sequence was not expected .github/workflows/main.yml (Line: 16, Col: 15): Unrecognized named-value: 'env'. Located at position 1 within expression: env.FRUITS" – Gerianne