66 - Matrix Object #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 66 - Matrix Object | |
on: | |
workflow_dispatch: | |
jobs: | |
orchestration: | |
runs-on: ubuntu-latest | |
outputs: | |
tasks: ${{ steps.tasks.outputs.tasks }} | |
steps: | |
- name: Build Tasks Array | |
id: tasks | |
run: | | |
myArray=() | |
myArray+=("{\"name\": \"task1\", \"type\":\"IAC\"}") | |
myArray+=("{\"name\": \"task2\", \"type\":\"DEPLOY\"}") | |
myArray+=("{\"name\": \"task3\", \"type\":\"DESTROY\"}") | |
myArray=$(jq --compact-output --null-input '$ARGS.positional' --args -- "${myArray[@]}") | |
echo "Updated tasks list: $myArray" | |
echo "tasks=$myArray" >> $GITHUB_OUTPUT | |
shell: bash | |
deploy: | |
runs-on: ubuntu-latest | |
needs: [orchestration] | |
strategy: | |
matrix: | |
stage: ${{ fromJSON(needs.orchestration.outputs.tasks) }} | |
fail-fast: true | |
max-parallel: 1 | |
# set the environment to use (environment must exist and be named the same as the stage here) | |
# environment: | |
# name: ${{ matrix.stage }} | |
steps: | |
# use environment specific secrets here for each stage | |
- name: Execute task ${{ matrix.stage }} | |
run: | | |
echo "Perform job executing task ${{ matrix.stage }}" | |
sleep 10 |