I just want it to run in Matrix for both INT,STG environments, and for each env I need the longer name (integration,staging).
Does this thing possible within github actions? did I miss something in the sytanx? I tried looking around for it and couldn't find it..
Test:
name: Deploy Test
runs-on: ${{matrix.env}}
strategy:
matrix:
env: [int, stg]
needs:
- 'jobA'
- 'jobB'
steps:
- name: Create test things.
env:
ENVIRONMENT: 'if github.runs-on == int; then $ENVIRONMENT=integration else $ENVIRONMENT=staging'
- name: Test
run: |
some command using ${{env.ENVIRONMENT}}
- Desired output is integration
some command using ${{env.ENVIRONMENT}}
- Desired output is staging
Thanks for anyone willing to assist!
CodePudding user response:
runs-on
is used to specify the machine name - you should not put any custom strings there.
The correct format looks like this:
Test:
name: Deploy Test
runs-on: ubuntu-latest
strategy:
matrix:
env: [int, stg]
needs:
- 'jobA'
- 'jobB'
steps:
- name: Create test things.
- uses: haya14busa/action-cond@v1
id: env_name
with:
cond: ${{ matrix.env == 'int' }}
if_true: "integration"
if_false: "staging"
- name: Test environment name
run: |
some command using ${{ matrix.env }} #int / stg will be passed
echo ${{ steps.env_name.outputs.value }} # will output integration for int, staging for stg
- name: Test Staging Only
if: matrix.env == 'stg'
run: |
some command using ${{ matrix.env }} #stg only, skipped for int
# This only executes for staging