diff --git a/.github/workflows/reusable.yml b/.github/workflows/reusable.yml new file mode 100644 index 0000000..1e4d59f --- /dev/null +++ b/.github/workflows/reusable.yml @@ -0,0 +1,28 @@ +name: Reusable workflow +on: + workflow_call: + inputs: + who-to-greet: + description: 'Person to greet' + type: string + required: true + default: 'World' + outputs: + current-time: + description: 'The time we greeted the person' + value: ${{ jobs.reusable-job.current-time }} + + +jobs: + reusable-job: + runs-on: ubuntu-latest + steps: + - name: Echo greeting + run: echo "Hello ${{ github.event.inputs.who-to-greet }}" + - name: Set current time + id: time + run: | + echo "::set-output name=current-time::$(date)" + outputs: + current-time: steps.time.outputs.current-time + \ No newline at end of file diff --git a/.github/workflows/reuse.yml b/.github/workflows/reuse.yml new file mode 100644 index 0000000..df3e0ab --- /dev/null +++ b/.github/workflows/reuse.yml @@ -0,0 +1,16 @@ +name: Reuse other workflow +on: + workflow_dispatch: +jobs: + call-workflow: + runs-on: ubuntu-latest + steps: + - name: Call reusable workflow + uses: ./.github/workflows/reusable.yml + with: + who-to-greet: ${{ github.actor }} + use-output: + runs-on: ubuntu-latest + needs: call-workflow + steps: + - run: echo "The time we greeted Alice was ${{ needs.call-workflow.outputs.current-time }}"