From 5b359c12f7fee4954223ae158f2b68fd4b45c9ca Mon Sep 17 00:00:00 2001 From: Kevin Meinhardt Date: Tue, 25 Jun 2024 19:33:38 +0200 Subject: [PATCH] Reusable workflow --- .github/workflows/default.yml | 6 ++++ .github/workflows/worker.yml | 64 +++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 .github/workflows/worker.yml diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 58ba1a2..848a08e 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -17,3 +17,9 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/context + call_worker: + uses: ./.github/workflows/worker.yml + with: + boolean: false + number: 1 + string: 'hello' diff --git a/.github/workflows/worker.yml b/.github/workflows/worker.yml new file mode 100644 index 0000000..5113357 --- /dev/null +++ b/.github/workflows/worker.yml @@ -0,0 +1,64 @@ +name: Worker + +on: + workflow_call: + inputs: + boolean: + description: 'A boolean input' + default: true + required: true + type: boolean + number: + description: 'A number input' + default: 0 + required: true + type: number + string: + description: 'A string input' + default: 'foo' + required: true + type: string + optional: + description: 'An optional input' + default: 'fallback' + required: false + type: string + outputs: + workflow_output1: + description: "The first job output" + value: ${{ jobs.output.outputs.one }} + workflow_output2: + description: "The second job output" + value: ${{ jobs.output.outputs.two }} + +concurrency: + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + context: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/context + + output: + runs-on: ubuntu-latest + + outputs: + one: ${{ steps.output.outputs.big }} + two: ${{ steps.test.outcome }} + steps: + - uses: actions/checkout@v4 + - id: output + shell: bash + run: | + echo "big=${{ github.event.inputs.number > 10 }}" >> $GITHUB_OUTPUT + - id: test + shell: bash + run: | + if [[ "${{ github.event.inputs.boolean }}" == 'true' ]]; then + exit 1 + fi + +