Skip to content

Commit 5b359c1

Browse files
committed
Reusable workflow
1 parent c6ee1cc commit 5b359c1

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

.github/workflows/default.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,9 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v4
1919
- uses: ./.github/actions/context
20+
call_worker:
21+
uses: ./.github/workflows/worker.yml
22+
with:
23+
boolean: false
24+
number: 1
25+
string: 'hello'

.github/workflows/worker.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Worker
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
boolean:
7+
description: 'A boolean input'
8+
default: true
9+
required: true
10+
type: boolean
11+
number:
12+
description: 'A number input'
13+
default: 0
14+
required: true
15+
type: number
16+
string:
17+
description: 'A string input'
18+
default: 'foo'
19+
required: true
20+
type: string
21+
optional:
22+
description: 'An optional input'
23+
default: 'fallback'
24+
required: false
25+
type: string
26+
outputs:
27+
workflow_output1:
28+
description: "The first job output"
29+
value: ${{ jobs.output.outputs.one }}
30+
workflow_output2:
31+
description: "The second job output"
32+
value: ${{ jobs.output.outputs.two }}
33+
34+
concurrency:
35+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
36+
cancel-in-progress: true
37+
38+
jobs:
39+
context:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
- uses: ./.github/actions/context
44+
45+
output:
46+
runs-on: ubuntu-latest
47+
48+
outputs:
49+
one: ${{ steps.output.outputs.big }}
50+
two: ${{ steps.test.outcome }}
51+
steps:
52+
- uses: actions/checkout@v4
53+
- id: output
54+
shell: bash
55+
run: |
56+
echo "big=${{ github.event.inputs.number > 10 }}" >> $GITHUB_OUTPUT
57+
- id: test
58+
shell: bash
59+
run: |
60+
if [[ "${{ github.event.inputs.boolean }}" == 'true' ]]; then
61+
exit 1
62+
fi
63+
64+

0 commit comments

Comments
 (0)