Skip to content

ci: Convert yaml to array-like matrix #9

ci: Convert yaml to array-like matrix

ci: Convert yaml to array-like matrix #9

Workflow file for this run

name: Dynamic Matrix Workflow
on:
push:
branches:
- main
- ci/test-automation
jobs:
prepare-matrix:
runs-on: ubuntu-latest
outputs:
dynamic-matrix: ${{ steps.convert-to-json.outputs.matrix }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Convert YAML to JSON
id: convert-to-json
run: |
json_output=$(yq eval -o=json .github/data/region.yml)
matrix_json=$(echo $json_output | jq -r '.regions | to_entries | map(.key as $service | .value[] | {service: $service, region: .})')
echo "matrix=$matrix_json" >> $GITHUB_OUTPUT
run-instances:
needs: prepare-matrix
runs-on: ubuntu-latest
strategy:
matrix:
region_service: ${{ fromJSON(needs.prepare-matrix.outputs.dynamic-matrix) }}
steps:
- name: Display matrix values
run: |
echo "Running for service: ${{ matrix.region_service.service }}"
echo "Running in region: ${{ matrix.region_service.region }}"