diff --git a/.github/workflows/reusable.yml b/.github/workflows/reusable.yml new file mode 100644 index 0000000..f095bc8 --- /dev/null +++ b/.github/workflows/reusable.yml @@ -0,0 +1,26 @@ +name: Reusable workflow + +on: + workflow_call: + inputs: + who-to-greet: + description: 'The person to greet' + type: string + required: true + default: World + outputs: + current-time: + description: 'The time when greeting.' + value: ${{ jobs.reusable-job.outputs.current-time }} +jobs: + reusable-job: + runs-on: ubuntu-latest + steps: + - name: Greet someone + run: echo "Hello ${{ inputs.who-to-greet }}" + - name: Set time + id: time + run: echo "time=$(date)" >> $GITHUB_OUTPUT + outputs: + current-time: ${{ steps.time.outputs.time }} + diff --git a/.github/workflows/reuse.yml b/.github/workflows/reuse.yml new file mode 100644 index 0000000..25d60b9 --- /dev/null +++ b/.github/workflows/reuse.yml @@ -0,0 +1,13 @@ +name: Reuse other workflow + +on: [workflow_dispatch] +jobs: + call-workflow: + uses: ./.github/workflows/reusable.yml + with: + who-to-greet: '@octocat' + use-output: + runs-on: ubuntu-latest + needs: [call-workflow] + steps: + - run: echo "Time was ${{ needs.call-workflow.outputs.current-time }}"