Skip to content

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

Update Prev-Step-Ref-Demo.yml

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

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
uses: actions/github-script@main
with:
script: |
const steps = JSON.parse(process.env['STEPS'])
const prevStep = steps[Object.keys(steps).pop()]
console.log(prevStep)
core.summary.addHeading('Previous step', '2')
core.summary.addCodeBlock(JSON.stringify(prevStep), 'json')
core.summary.write()
env:
'STEPS': ${{ toJSON(steps) }}