How to set global variable across workflows?

Hi,

I’ve a python based project where I use multiple workflows. In each workflow there are multiple jobs which run on a python container. Currently, I duplicated the image tag string at all places. I want to be able to read the tag from some global variable so that updating tag in future will be easy.

Here is an example -

$ cat workflow1.yaml
name: "Workflow 1"
on: push
jobs:
  job1:
    runs-on: ubuntu-latest
    container: python:3.8
    ...
  job2:
    runs-on: ubuntu-latest
    container: python:3.8
    ...
$ cat workflow2.yaml
name: "Workflow 2"
on: push
jobs:
  job3:
    runs-on: ubuntu-latest
    container: python:3.8
    ...
  job4:
    runs-on: ubuntu-latest
    container: python:3.8
    ...

I want to be able to define the version to some variable and read from there. I couldn’t find any option to do so for all job in a workflow or across all workflows.

Can someone tell me, if this is possible? And if yes, what I’m doing wrong.

Thanks!
Kanak

That’s not possible. The closest you could do would be to have an initial job in each workflow that reads some sort of config file from your repository and provides the values you want as outputs.

Stick it into a file and have a step (or if you really want to an action or reusable workflow) to read the file into something. It could put the value into a variable in $GITHUB_ENV.

The env context is not going to work to define job containers, for purposes where it works that’d be the simplest solution.

I want to use this in jobs.<job_id>.container. So, I can’t call any step before it.

Create another job in the workout file and have it generate an output. Then use needs to get the output from the job for use here.