Skip to content

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

Update Prev-Step-Ref-Demo.yml

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

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_VALUE" >> $GITHUB_OUTPUT
- name: "Step #1"
id: 'step1'
run: |
echo "value=STEP_1_VALUE" >> $GITHUB_OUTPUT
- name: "Step #2"
id: 'step2'
run: |
echo "value=STEP_2_VALUE" >> $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, null, " "), 'json')
core.summary.write()
env:
'STEPS': ${{ toJSON(steps) }}