Try a reusable workflow
2 files+45−00/2 viewed
| 1 | + | name: Caller | |
| 2 | + | on: | |
| 3 | + | workflow_dispatch: | |
| 4 | + | jobs: | |
| 5 | + | greet: | |
| 6 | + | uses: ./.github/workflows/reusable-greet.yml | |
| 7 | + | with: | |
| 8 | + | who: g1t | |
| 9 | + | loud: true | |
| 10 | + | report: | |
| 11 | + | needs: greet | |
| 12 | + | runs-on: ubuntu-latest | |
| 13 | + | steps: | |
| 14 | + | - run: echo "reusable said ${{ needs.greet.outputs.message }} (${{ needs.greet.result }})" |
| 1 | + | name: Greet (reusable) | |
| 2 | + | on: | |
| 3 | + | workflow_call: | |
| 4 | + | inputs: | |
| 5 | + | who: | |
| 6 | + | type: string | |
| 7 | + | required: true | |
| 8 | + | loud: | |
| 9 | + | type: boolean | |
| 10 | + | default: false | |
| 11 | + | outputs: | |
| 12 | + | message: | |
| 13 | + | description: What was said | |
| 14 | + | value: ${{ jobs.say.outputs.said }} | |
| 15 | + | jobs: | |
| 16 | + | say: | |
| 17 | + | runs-on: ubuntu-latest | |
| 18 | + | outputs: | |
| 19 | + | said: ${{ steps.greet.outputs.said }} | |
| 20 | + | steps: | |
| 21 | + | - id: greet | |
| 22 | + | run: | | |
| 23 | + | msg="hello, ${{ inputs.who }}" | |
| 24 | + | if [ "${{ inputs.loud }}" = "true" ]; then msg="${msg^^}!"; fi | |
| 25 | + | echo "$msg" | |
| 26 | + | echo "said=$msg" >> "$GITHUB_OUTPUT" | |
| 27 | + | after: | |
| 28 | + | needs: say | |
| 29 | + | runs-on: ubuntu-latest | |
| 30 | + | steps: | |
| 31 | + | - run: echo "the greeting was ${{ needs.say.outputs.said }}" |