I would like to define some nested env variables like this:
name: push-deploy-docker
on:
push:
branches:
- 'develop'
- 'master'
env:
AWS_ENV: "${{ github.ref_name == 'master' && 'prod' || contains(github.ref_name, 'release') && 'qa' || 'dev' }}"
dev:
AWS_ACCESS_KEY_ID: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
qa:
AWS_ACCESS_KEY_ID: ${{ secrets.QA_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.QA_AWS_SECRET_ACCESS_KEY }}
So that at the jobs section of Github actions, I could have the dynamic call:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ [env.AWS_ENV]AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ [env.AWS_ENV]AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ [env.AWS_ENV]AWS_DEFAULT_REGION }}
When I run, Github tells me that the workflows at the env section is not valid, and the error is: "A mapping was not expected". Is there any way that I can define the env like that?