Skip to content

Commit 4694f67

Browse files
committed
label-target: make it reusable
In some cases it might be handy to quickly smoke test certain types of changes, where it usually doesn't make sense to build everything, so lets allow that with reusable label-target workflow, which can be easily reusable by just passing target/subtarget inputs. References: openwrt/openwrt#16784 Signed-off-by: Petr Štetiar <ynezz@true.cz>
1 parent 5fd7d92 commit 4694f67

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

.github/workflows/label-target.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33
name: Build check target specified in labels
44
on:
55
workflow_call:
6+
inputs:
7+
target:
8+
type: string
9+
subtarget:
10+
type: string
611

712
jobs:
813
set_target:
9-
if: startsWith(github.event.label.name, 'ci:target:')
14+
if: startsWith(github.event.label.name, 'ci:target:') || inputs.target != ''
1015
name: Set target
1116
runs-on: ubuntu-latest
1217
outputs:
@@ -19,8 +24,23 @@ jobs:
1924
env:
2025
CI_EVENT_LABEL_NAME: ${{ github.event.label.name }}
2126
run: |
22-
echo "$CI_EVENT_LABEL_NAME" | sed -n 's/.*:\(.*\):\(.*\)$/target=\1/p' | tee --append $GITHUB_OUTPUT
23-
echo "$CI_EVENT_LABEL_NAME" | sed -n 's/.*:\(.*\):\(.*\)$/subtarget=\2/p' | tee --append $GITHUB_OUTPUT
27+
if [ -n "${{ inputs.target}}" ]; then
28+
target="${{ inputs.target }}"
29+
else
30+
target=$(echo "$CI_EVENT_LABEL_NAME" | sed -n 's/.*:\(.*\):\(.*\)$/\1/p')
31+
fi
32+
33+
if [ -n "${{ inputs.subtarget}}" ]; then
34+
subtarget="${{ inputs.subtarget }}"
35+
else
36+
subtarget=$(echo "$CI_EVENT_LABEL_NAME" | sed -n 's/.*:\(.*\):\(.*\)$/\2/p')
37+
fi
38+
39+
echo "Setting target as $target, subtarget as $subtarget"
40+
{
41+
echo "target=$target"
42+
echo "subtarget=$subtarget"
43+
} >> "$GITHUB_OUTPUT"
2444
2545
build_target:
2646
name: Build target

0 commit comments

Comments
 (0)