I am struggling with getting “computed” (environment) variables to work.
I have tried and looked at :
https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
Github Actions, how to share a calculated value between job steps?
https://github.com/GuillaumeFalourd/poc-github-actions/blob/main/.github/workflows/53-concatenation.yml
Most of the examples I have seen are setting a SINGLE computed-variable, not multiples.
At the end of this, I would like to see
FullSentence=The green dog jumped in the air 555 times.
where 555 is the GIT_HUB_RUN_NUMBER from https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
Below is my latest attempt, trying to mimic what is coming from docs.github link above about multi-lines. SELECTED_COLOR is straight from the docs.github example. (I’d added more items to get a full sentence).
Here is my yml contents
name: Deploy
on:
push:
branches: [ "main" ]
paths-ignore:
- 'README.md'
- '.github/**'
pull_request:
branches: [ "main" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
THE_ANIMAL: dog
jobs:
jobOne:
runs-on: [ your_runner_here ]
- name: Create dynamic Environment Variable 1
id: idabcxyz
run: |
{
run: echo "SELECTED_COLOR=green" >> "$GITHUB_OUTPUT"
run: echo "SELECTED_ANIMAL=dog" >> "$GITHUB_OUTPUT"
run: echo "SELECTED_COUNT=${GITHUB_RUN_NUMBER}" >> "$GITHUB_OUTPUT"
}
- name: Show ENV Variables
env:
theSelectedColor: ${{ steps.idabcxyz.outputs.SELECTED_COLOR }}
theSelectedAnimal: ${{ steps.idabcxyz.outputs.SELECTED_ANIMAL }}
theCount: ${{ steps.idabcxyz.outputs.SELECTED_COUNT }}
run: |
echo "THE_ANIMAL=${{ env.THE_ANIMAL }}"
echo "theSelectedColor=$theSelectedColor"
echo "theSelectedAnimal=$theSelectedAnimal"
echo "theCount=$theCount"
echo "FullSentence=The $theSelectedColor ${{ env.THE_ANIMAL }} jumped in the air $theCount times."