Skip to content

use shell env syntax #11

use shell env syntax

use shell env syntax #11

Workflow file for this run

name: Hi Mascot
on: push
# global env var
env:
mascot: Mona
defaults:
run:
shell: bash
jobs:
windows_job:
name: Windows Job
runs-on: ubuntu-latest
steps:
- name: uses wf env
run: echo 'Hi ${{ env.mascot }}' # Hi Mona
- name: uses step env
run: echo 'Hi ${{ env.mascot }}' # Hi Octocat
env:
mascot: Octocat
linux_job:
name: Linux Job
needs: windows_job
runs-on: ubuntu-latest
env:
mascot: Tux
outputs:
mascot: ${{ steps.outstep.outputs.mascot }}
steps:
- name: uses job env
run: echo 'Hi ${{ env.mascot }}' # Hi Tux
- name: set gritty env var
run: echo "mascot=Gritty" >> $GITHUB_ENV
- name: uses changed job env
run: echo 'Hi ${{ env.mascot }}' # Hi Gritty
- name: uses step env
run: echo "Hi ${{ env.mascot }}" # Hi Mika
env:
mascot: Mika
- name: uses job env again
run: echo 'Hi ${{ env.mascot }}' # Hi Gritty
- name: set output using job env
id: outstep
run: echo "mascot=$mascot" >> $GITHUB_OUTPUT # Gritty
macos_job:
name: macOS Job
needs: windows_job
runs-on: ubuntu-latest
steps:
- name: uses wf env
run: echo 'Hi ${{ env.mascot }}' # Hi Mona
- name: uses prior job output
run: echo 'Hi ${{ needs.linux_job.outputs.mascot }}' # Hi Gritty
post:
name: Post
runs-on: ubuntu-latest
# always runs, regardless of the outcome of any of the previous steps
if: always()
needs: [linux_job, macos_job]
steps:
- name: Post
run: |
echo 'Post Steps, such as notifications, etc.'
echo "::notice::I'm a post step!"
echo "::error::What do we need to do in Post?"