Skip to content

Commit 39a8711

Browse files
committed
ci: support for conditionally executing matrix steps if tags are relevant
Signed-off-by: Tom Carrio <[email protected]>
1 parent bc1ecb2 commit 39a8711

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

Diff for: .github/workflows/split_monorepo.yaml

+25-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ name: split-monorepo
22
on:
33
release:
44
types: [published]
5+
workflow_dispatch:
6+
inputs:
7+
tag:
8+
description: 'Package tag'
9+
type: string
10+
required: true
511

612
jobs:
713
split-repositories:
@@ -21,21 +27,39 @@ jobs:
2127
- [provider, split, Split]
2228
- [provider, go-feature-flag, GoFeatureFlag]
2329
steps:
30+
- name: Detect run requirement
31+
id: shouldRun
32+
run: |
33+
input_ref="${{ github.event.release.tag_name }}"
34+
if [ -z "$input_ref" ]; then
35+
input_ref="${{ inputs.tag }}"
36+
fi
37+
result=0
38+
if [[ "$inputRef" == open-feature/${{ matrix.config[1] }}-${{ matrix.config[0] }}-* ]]; then
39+
result=1
40+
fi
41+
echo "::set-output name=result::${result}"
2442
- name: checkout
43+
if: ${{ steps.shouldRun.outputs.result == '1' }}
2544
run: |
2645
git clone "$GITHUB_SERVER_URL"/"$GITHUB_REPOSITORY" "$GITHUB_WORKSPACE"
2746
cd "$GITHUB_WORKSPACE"
2847
git checkout "$GITHUB_SHA"
2948
- name: Replace string in GitHub Actions
49+
if: ${{ steps.shouldRun.outputs.result == '1' }}
3050
id: targetRef
3151
run: |
3252
input_ref="${{ github.event.release.tag_name }}"
53+
if [ -z "$input_ref" ]; then
54+
input_ref="${{ inputs.tag }}"
55+
fi
3356
if [ -n "$input_ref" ]; then
3457
input_ref="refs/tags/$input_ref"
3558
target_ref="$(echo -n "$input_ref"|sed 's#open-feature/${{ matrix.config[1] }}-${{ matrix.config[0] }}-##')"
3659
fi
3760
echo "::set-output name=result::${target_ref}"
38-
- name: filter-and-push-package-${{ matrix.config[1] }}-${{ matrix.config[0] }}
61+
- name: Filter and push package ${{ matrix.config[1] }}-${{ matrix.config[0] }}
62+
if: ${{ steps.shouldRun.outputs.result == '1' }}
3963
uses: tcarrio/[email protected]
4064
with:
4165
privateKey: ${{ secrets.SSH_PRIVATE_KEY }}

0 commit comments

Comments
 (0)