This issue is reproducible. Simply paste the receivertest.yml
in your GitHub workflow and you will see the error I m reporting.
Below is my caller workflow callertest.yml
file:
---
name: Testcasecaller
on:
workflow_dispatch
jobs:
call-reusable-workflow:
uses: knowyrtech/DevOps/.github/workflows/receivertest.yml@newmmtmp
secrets: inherit
Here is my called workflow receivertest.yml
that uses strategy matrix on 2 self-hosted runners viz linuxrunner
and winrunner
:
---
name: refresh_poc - AD
env:
linuxrunner: '0361'
winrunner: '1567'
on:
workflow_call:
inputs:
srcDBenv:
description: 'Source Environment'
required: false
type: string
default: 'STG'
secrets:
AUTOMATED_TOKEN:
description: 'DevOps github repo secret'
required: true
jobs:
SETVARS:
name: Set variables
outputs:
formatdate: "${{ steps.get-date.outputs.formatdate }}"
runs-on: ${{ linuxrunner }}
steps:
- name: Get present date
id: get-date
run: |
date=$(date +"%d%b%Y")
echo "formatdate=$date" >> $GITHUB_OUTPUT
TAKING_PROD_DATABASE_BACKUP:
name: Taking backup
needs:
- SETVARS
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 1
matrix:
os: [${{ env.winrunner }}, ${{ env.linuxrunner }}]
steps:
- name: Checkout
env:
ATOTOKEN: ${{ secrets.AUTOMATED_TOKEN }}
with:
repository: knowyrtech/DevOps
ref: newmmtmp
path: DevOps
sparse-checkout: |
scripts
sparse-checkout-cone-mode: false
token: ${{ env.ATOTOKEN }}
if: matrix.os == ${{ env.winrunner }}
Error when action is run:
Invalid workflow file: .github/workflows/callertest.yml#L10
error parsing called workflow ".github/workflows/callertest.yml" -> knowyrtech/DevOps/.github/workflows/receivertest.yml@newmmtmp (source branch with sha:fdb50734f2e37ecaa1eaf469ebfcad75de3c1fb7) : You have an error in your yaml syntax on line 49
I tried os: [${{ winrunner }}, ${{ linuxrunner }}]
but that too did not work.
The editor prompts an error as: missed comma between flow collection entries
but as you can see the comma is very well there.
I tried setting the combined runners as outputs
and feeding the outputs
to the strategy matrix but then I get error Error when evaluating 'strategy' for job
set-vars:
runs-on: ubuntu-latest
outputs:
os-matrix: ${{ steps.set-vars.outputs.os-matrix }}
steps:
- name: Set matrix values
id: set-vars
run: |
echo "os-matrix=${{ env.winrunner }},${{ env.linuxrunner }}" >> $GITHUB_OUTPUT
and
os: fromJson(${{ NEEDS.SET-VARS.OUTPUTS.OS-MATRIX }})
While troubleshooting the issue I also landed on syntax error for runs-on: ${{ linuxrunner }}
or runs-on: ${{ env.linuxrunner }}
Can you please suggest what the issue is with my workflow code?