If you have a job or step that has many outputs that you would like to set as envs (in the shell), do this:
name:
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Set some outputs via GITHUB_OUTPUT
id: set_outputs
run: |
echo "VAR_1=some_value_1" >> $GITHUB_OUTPUT
echo "VAR_2=some_value_2" >> $GITHUB_OUTPUT
echo "VAR_3=some_value_3" >> $GITHUB_OUTPUT
echo "VAR_4=some_value_4" >> $GITHUB_OUTPUT
echo "VAR_5=some_value_5" >> $GITHUB_OUTPUT
- name: Echo all outputs to GITHUB_ENV
run: >
echo '${{ toJSON(steps.set_outputs.outputs) }}'
| jq -r 'to_entries[]
| "\(.key)=\(.value)"'
>> $GITHUB_ENV
- name: Verify vars in GITHUB_ENV
run: |
# Now should log 'some_value_1'
echo $VAR_1