Skip to content

Run with reusable steps #8

Run with reusable steps

Run with reusable steps #8

name: Run with reusable steps # with composite action
on:
workflow_dispatch: # Manually trigger the workflow
defaults:
run:
shell: bash
jobs:
job-1:
runs-on: ubuntu-latest
steps:
- name: Print Hello World
run: echo "Hello World"
- name: Create a file
run: echo "Hello World" > input.txt
- uses: actions/upload-artifact@v4
with:
name: input_file
path: input.txt
job-2:
needs: job-1
runs-on: ubuntu-latest
# Map the job output(s) to step output(s)
outputs:
job_output: ${{ steps.reusable-steps.outputs.reusable_output }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: input_file
- name: Use reusable steps
id: reusable-steps
uses: ./.github/reusable-steps # To use this syntax, we must have the repository checked out
with:
reusable_input: "job-2-input"
filename: "input.txt"
env:
HELLO_WORLD_SECRET: TERCES_DLROW_OLLEH
- uses: actions/upload-artifact@v4
with:
name: output_file
path: input.txt
job-3:
needs: job-2
runs-on: ubuntu-latest
steps:
- name: Print output
run: echo "reusable_output=${{ needs.job-2.outputs.job_output }}"
- uses: actions/download-artifact@v4
with:
name: output_file
- name: Print file content
run: cat input.txt