You can write your variables and values, which you want to pass, to a file and upload it as an artifact in the triggering workflow.
In the triggered workflow, download the artifact of the triggering workflow run. Then parse the file to get your variables.
Triggering workflow
[...]
name: Build
jobs:
aJob:
name: A job
runs-on: ubuntu-latest
steps:
- run: echo "aVariable,aValue" > vars.csv
- uses: actions/upload-artifact@v2
with:
name: variables
path: vars.csv
Triggered workflow
(artifacts from other workflows can't be downloaded with the action download-artifact
)
on:
workflow_run:
workflows: ["Build"]
types: [completed]
jobs:
aJob:
name: A job
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v4
id: get-artifact-id
with:
result-encoding: string
script: |
const result = await octokit.request('GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts', {
owner: '${{github.repository_owner}}',
repo: '${{github.event.repository.name}}',
run_id: ${{github.event.workflow_run.id}}
})
# assumes the variables artifact is the only one in this workflow
return result.data.artifacts[0].artifact_id
- name: Get result
run: |
echo "${{steps.get-artifact-id.outputs.result}}"
curl -L -H "Authorization: token ${{github.token}}" \
-H "Accept: application/vnd.github.v3+json" \
-O variables.zip \
https://api.github.com/repos/${{github.repository}}/actions/artifacts/${{steps.get-artifact-id.outputs.result}}/zip
unzip variables.zip
# parse variables from variables.csv and set them