I currently have a requirement to set up four jobs in a matrix strategy in GitHub Actions. If the conditions are met, the job will be executed, otherwise, it will be skipped. Is it possible to achieve this?
With the current code, I am only able to skip the steps but not the entire job. Can anyone provide guidance on how to set conditions in the matrix strategy to skip the entire job if the conditions are not met?
jobs:
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- uppercase_env: 'DEV'
lowercase_env: 'dev'
secrets_prefix: 'dev_'
deploy_condition: ${{ contains(github.ref_name, 'develop') && !inputs.env_name }}
- uppercase_env: 'TST'
lowercase_env: 'tst'
secrets_prefix: 'tst_'
deploy_condition: ${{ contains(github.ref_name, 'develop') && !inputs.env_name }}
- uppercase_env: 'STG'
lowercase_env: 'stg'
secrets_prefix: 'stg_'
deploy_condition: ${{ contains(github.ref_name, 'release') && inputs.env_name == 'STG' }}
- uppercase_env: 'PRD'
lowercase_env: 'prd'
secrets_prefix: 'prd_'
deploy_condition: ${{ (contains(github.ref_name, 'release') || contains(github.ref_name, 'hotfix')) && inputs.env_name == 'PRD' }}
steps:
- name: Do something
if: matrix.deploy_condition