From bcc0862a0736eb9ba89c12c578cd7ecc30a2b3c6 Mon Sep 17 00:00:00 2001 From: ahmedbham <16580429+ahmedbham@users.noreply.github.com> Date: Sun, 14 Apr 2024 11:42:27 -0700 Subject: [PATCH] two new workflows --- .github/workflows/reusable.yml | 28 ++++++++++++++++++++++++++++ .github/workflows/reuse.yml | 16 ++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 .github/workflows/reusable.yml create mode 100644 .github/workflows/reuse.yml 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 }}"