Skip to content

chore(deps): update actions/checkout action to v4 #424

chore(deps): update actions/checkout action to v4

chore(deps): update actions/checkout action to v4 #424

name: matrix-from-previous-job-output-2
on:
pull_request:
jobs:
setup:
outputs:
DEV_CHANGED: ${{ steps.changed-files-yaml.outputs.dev_any_changed }}
PROD_CHANGED: ${{ steps.changed-files-yaml.outputs.prod_any_changed }}
CHANGED_ENVS: ${{ steps.matrix.outputs.CHANGED_ENVS }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0 # OR "2" -> To retrieve the preceding commit.
- name: get all changes for static/dev and static/prod
id: changed-files-yaml
uses: tj-actions/changed-files@v41
with:
files_yaml: |
dev:
- 'static/dev/**'
prod:
- 'static/prod/**'
- id: matrix
run: |
echo "dev: ${{ steps.changed-files-yaml.outputs.dev_any_changed }}" >> "$GITHUB_STEP_SUMMARY"
echo "prod: ${{ steps.changed-files-yaml.outputs.prod_any_changed }}" >> "$GITHUB_STEP_SUMMARY"
echo "CHANGED_ENVS=$(echo "[{\"env\": \"dev\", \"changed\": ${{ steps.changed-files-yaml.outputs.dev_any_changed }}}, {\"env\":\"prod\", \"changed\": ${{ steps.changed-files-yaml.outputs.prod_any_changed }} }]" | jq -c 'map(select( .changed ).env)')" >> "$GITHUB_OUTPUT"
execute:
if: needs.setup.outputs.CHANGED_ENVS != '[]'
strategy:
matrix:
env: ${{ fromJson(needs.setup.outputs.CHANGED_ENVS) }}
runs-on: ubuntu-latest
needs: [setup]
# if: ${{ matrix.env == 'dev' }} ❌ matrix value can be used only in steps
steps:
- run: |
echo "matrix: ${{ matrix.env }}"