Replies: 1 comment 3 replies
-
|
Hey there! I can see what's happening here. The issue is that your The problem is in how you're defining your matrix strategy. You're trying to use Here's what you need to change: Notice the key difference: Then in your job steps, you'd reference the matrix values like:
This will create one job execution for each object in your instances array, and each job will have access to that specific instance's Hope this helps! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Why are you starting this discussion?
Question
What GitHub Actions topic or product is this about?
Workflow Configuration
Discussion Details
Hello, I have a question regarding passing a list of objects to matrix strategy.
outputs:
instances: ${{ steps.pick.outputs.instances }}
script_path: ${{ steps.pick.outputs.script_path }}
name: Resolve instances + script path (jq, no status filter)
id: pick
shell: bash
run: |
set -euo pipefail
case "${{ inputs.action }}" in
pull) SCRIPT_PATH="/var/lib/cloud/app/pull_image.sh" ;;
deploy) SCRIPT_PATH="/var/lib/cloud/app/deploy_docker.sh" ;;
*) echo "Nieznana action"; exit 1 ;;
esac
echo "script_path=${SCRIPT_PATH}" >> "$GITHUB_OUTPUT"
exec:
needs: resolve
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 1
matrix: ${{ fromJSON(needs.resolve.outputs.instances) }}
env:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
SCRIPT_PATH: ${{ needs.resolve.outputs.script_path }}
Here I am passing to strategy list of VMs on which I want to execute a script.
Debug step is showing a correct json:
steps.pick.outputs.instances (raw below):
[
]
and first part of the pipeline ends up with success. But the second part throws an error:
Error when evaluating 'strategy' for job 'exec'. .github/workflows/pull_run_docker_image.yml (Line: 120, Col: 15): Error from function 'fromJSON': empty input, .github/workflows/pull_run_docker_image.yml (Line: 120, Col: 15): Unexpected value ''
Thank you in advance for your help!
Beta Was this translation helpful? Give feedback.
All reactions