Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Pilot Lvl 1
Message 1 of 7

[GitHub Actions (new)] [BUG] Unable to create environment variables based matrix

Solved! Go to Solution.

Here's what I'm trying:

 

jobs:
  build:

    runs-on: ubuntu-latest
    strategy:
      max-parallel: 4
      matrix:
        python-version:
        - 3.7
        os:
        - ubuntu-18.04
        env:
        - TOXENV: python,check-docs,build-docs
- TOXENV: build-dists,pre-commit-ci

 

 

I want to generate a number of jobs from matrix also taking into account the specified env vars. Just like Travis CI does:

 

Anything I'm missing?

6 Replies
Highlighted
Community Manager
Message 2 of 7

Re: [GitHub Actions] (new) Unable to create environment variables based matrix

Hi @webknjaz, thanks for being here! Did you give this workflow a go? Are you having any problems?


Best,
AndreaG

Mark helpful posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great content!

Highlighted
Pilot Lvl 1
Message 3 of 7

Re: [GitHub Actions] (new) Unable to create environment variables based matrix

Hi @AndreaGriffiths11, I tried it and it doesn't create jobs with different env var values from the matrix.

Highlighted
Solution
Pilot Lvl 1
Message 4 of 7

Re: [GitHub Actions (new)] [BUG] Unable to create environment variables based matrix

Workaround is to explicitly apply the env factor on a job level:

jobs:
  build:

    runs-on: ubuntu-latest
    strategy:
      max-parallel: 4
      matrix:
        python-version:
        - 3.7
        os:
        - ubuntu-18.04
        env:
        - TOXENV: python,check-docs,build-docs
- TOXENV: build-dists,pre-commit-ci
steps:
- ...
- run: |
some-command --with-access-to=env
env: ${{ matrix.env }}

 

Highlighted
Copilot Lvl 3
Message 5 of 7

Re: [GitHub Actions (new)] [BUG] Unable to create environment variables based matrix

Highlighted
Pilot Lvl 1
Message 6 of 7

Re: [GitHub Actions (new)] [BUG] Unable to create environment variables based matrix

That's essentially the same except that with GH Actions you have to expose vars to each job explicitly.

Highlighted
Pilot Lvl 1
Message 7 of 7

Re: [GitHub Actions (new)] [BUG] Unable to create environment variables based matrix

I just checked and it turns out that you can use env: on the job level too now: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-...