Skip to content

Update Prev-Step-Ref-Demo.yml #2

Update Prev-Step-Ref-Demo.yml

Update Prev-Step-Ref-Demo.yml #2

name: "Previous Step Referencing Demo"
on:
push:
branches:
- master
paths:
- ".github/workflows/Prev-Step-Ref-Demo.yml"
workflow_dispatch:
jobs:
'demo':
runs-on: 'ubuntu-latest'
steps:
- name: "Step #0"
id: step0
run: echo "value=STEP_0" >> $GITHUB_OUTPUT
- name: "Step #1"
id: step1
run: echo "value=STEP_1" >> $GITHUB_OUTPUT
- name: "Step #2"
id: step2
run: echo "value=STEP_2" >> $GITHUB_OUTPUT
- name: Use the output from the previous step
# run: echo "The output from the previous step is: "
shell: node {0}
run: |
const steps = JSON.parse(process.env['STEPS'])
const prevStep = steps[Object.keys(steps).pop()]
console.log(prevStep)
env:
'STEPS': ${{ toJSON(steps) }}