Skip to content

Commit fb4da77

Browse files
authored
ci: use new git-filter-repo based action with tag filtering support for splitting monorepo to PHP packages (#110)
* feat: support for splitting all repos including GoFeatureFlag from single matrix ci: support for running from split branch chore: remove outdated gitsplit config fix: tag rename rule chore: debug info postcheckout chore: disable all but one in matrix for validation ci: fix closing str ci: fix reference to subdir feat: push implicit tags from prefilter operation chore: update to latest fixed action chore: empty commit bump chore: update to tag output version of action fix: tag reference has package type as suffix before version ci: revert versions to next major to support new deployment structure ci: revert versions to next major to support new deployment structure chore: bump to latest version of action ci: pass reference for targetBranch or nothing if not provided ci: execute from releases only Signed-off-by: Tom Carrio <[email protected]> * ci: support for conditionally executing matrix steps if tags are relevant Signed-off-by: Tom Carrio <[email protected]> --------- Signed-off-by: Tom Carrio <[email protected]>
1 parent 9f1f9f9 commit fb4da77

File tree

4 files changed

+75
-133
lines changed

4 files changed

+75
-133
lines changed

.github/workflows/split_monorepo.yaml

Lines changed: 61 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -2,102 +2,72 @@ 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:
7-
split-hook-dd-trace:
13+
split-repositories:
814
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
# Structure of the config tuple is:
18+
# 0: Type of package (e.g. open-feature/flagd-*provider*)
19+
# 1: Name of package (sans-org-prefix e.g. open-feature/*flagd*-provider)
20+
# 2: Name of subdirectory (e.g. providers/*Flagd*)
21+
config:
22+
- [hook, dd-trace, DDTrace]
23+
- [hook, otel, OpenTelemetry]
24+
- [hook, validator, Validators]
25+
- [provider, cloudbees, CloudBees]
26+
- [provider, flagd, Flagd]
27+
- [provider, split, Split]
28+
- [provider, go-feature-flag, GoFeatureFlag]
929
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}"
1042
- name: checkout
11-
run: git clone "$GITHUB_SERVER_URL"/"$GITHUB_REPOSITORY" "$GITHUB_WORKSPACE" && cd "$GITHUB_WORKSPACE" && git checkout "$GITHUB_SHA"
12-
- name: push-hook-dd-trace
13-
uses: tcarrio/git-filter-repo-docker-action@v1
43+
if: ${{ steps.shouldRun.outputs.result == '1' }}
44+
run: |
45+
git clone "$GITHUB_SERVER_URL"/"$GITHUB_REPOSITORY" "$GITHUB_WORKSPACE"
46+
cd "$GITHUB_WORKSPACE"
47+
git checkout "$GITHUB_SHA"
48+
- name: Replace string in GitHub Actions
49+
if: ${{ steps.shouldRun.outputs.result == '1' }}
50+
id: targetRef
51+
run: |
52+
input_ref="${{ github.event.release.tag_name }}"
53+
if [ -z "$input_ref" ]; then
54+
input_ref="${{ inputs.tag }}"
55+
fi
56+
if [ -n "$input_ref" ]; then
57+
input_ref="refs/tags/$input_ref"
58+
target_ref="$(echo -n "$input_ref"|sed 's#open-feature/${{ matrix.config[1] }}-${{ matrix.config[0] }}-##')"
59+
fi
60+
echo "::set-output name=result::${target_ref}"
61+
- name: Filter and push package ${{ matrix.config[1] }}-${{ matrix.config[0] }}
62+
if: ${{ steps.shouldRun.outputs.result == '1' }}
63+
uses: tcarrio/[email protected]
1464
with:
1565
privateKey: ${{ secrets.SSH_PRIVATE_KEY }}
1666
targetOrg: open-feature-php
17-
targetRepo: dd-trace-hook
18-
targetBranch: refs/tags/${{ github.event.release.tag_name }}
19-
filterArguments: '--subdirectory-filter hooks/DDTrace/ --force'
20-
21-
split-hook-otel:
22-
runs-on: ubuntu-latest
23-
steps:
24-
- name: checkout
25-
run: git clone "$GITHUB_SERVER_URL"/"$GITHUB_REPOSITORY" "$GITHUB_WORKSPACE" && cd "$GITHUB_WORKSPACE" && git checkout "$GITHUB_SHA"
26-
- name: push-hook-otel
27-
uses: tcarrio/git-filter-repo-docker-action@v1
28-
with:
29-
privateKey: ${{ secrets.SSH_PRIVATE_KEY }}
30-
targetOrg: open-feature-php
31-
targetRepo: otel-hook
32-
targetBranch: refs/tags/${{ github.event.release.tag_name }}
33-
filterArguments: '--subdirectory-filter hooks/OpenTelemetry/ --force'
34-
35-
split-hook-validator:
36-
runs-on: ubuntu-latest
37-
steps:
38-
- name: checkout
39-
run: git clone "$GITHUB_SERVER_URL"/"$GITHUB_REPOSITORY" "$GITHUB_WORKSPACE" && cd "$GITHUB_WORKSPACE" && git checkout "$GITHUB_SHA"
40-
- name: push-hook-validator
41-
uses: tcarrio/git-filter-repo-docker-action@v1
42-
with:
43-
privateKey: ${{ secrets.SSH_PRIVATE_KEY }}
44-
targetOrg: open-feature-php
45-
targetRepo: validators-hook
46-
targetBranch: refs/tags/${{ github.event.release.tag_name }}
47-
filterArguments: '--subdirectory-filter hooks/Validators/ --force'
48-
49-
split-provider-cloudbees:
50-
runs-on: ubuntu-latest
51-
steps:
52-
- name: checkout
53-
run: git clone "$GITHUB_SERVER_URL"/"$GITHUB_REPOSITORY" "$GITHUB_WORKSPACE" && cd "$GITHUB_WORKSPACE" && git checkout "$GITHUB_SHA"
54-
- name: push-provider-cloudbees
55-
uses: tcarrio/git-filter-repo-docker-action@v1
56-
with:
57-
privateKey: ${{ secrets.SSH_PRIVATE_KEY }}
58-
targetOrg: open-feature-php
59-
targetRepo: cloudbees-provider
60-
targetBranch: refs/tags/${{ github.event.release.tag_name }}
61-
filterArguments: '--subdirectory-filter providers/CloudBees/ --force'
62-
63-
split-provider-flagd:
64-
runs-on: ubuntu-latest
65-
steps:
66-
- name: checkout
67-
run: git clone "$GITHUB_SERVER_URL"/"$GITHUB_REPOSITORY" "$GITHUB_WORKSPACE" && cd "$GITHUB_WORKSPACE" && git checkout "$GITHUB_SHA"
68-
- name: push-provider-flagd
69-
uses: tcarrio/git-filter-repo-docker-action@v1
70-
with:
71-
privateKey: ${{ secrets.SSH_PRIVATE_KEY }}
72-
targetOrg: open-feature-php
73-
targetRepo: flagd-provider
74-
targetBranch: refs/tags/${{ github.event.release.tag_name }}
75-
filterArguments: '--subdirectory-filter providers/Flagd/ --force'
76-
77-
split-provider-split:
78-
runs-on: ubuntu-latest
79-
steps:
80-
- name: checkout
81-
run: git clone "$GITHUB_SERVER_URL"/"$GITHUB_REPOSITORY" "$GITHUB_WORKSPACE" && cd "$GITHUB_WORKSPACE" && git checkout "$GITHUB_SHA"
82-
- name: push-provider-split
83-
uses: tcarrio/git-filter-repo-docker-action@v1
84-
with:
85-
privateKey: ${{ secrets.SSH_PRIVATE_KEY }}
86-
targetOrg: open-feature-php
87-
targetRepo: split-provider
88-
targetBranch: refs/tags/${{ github.event.release.tag_name }}
89-
filterArguments: '--subdirectory-filter providers/Split/ --force'
90-
91-
split-provider-go-feature-flag:
92-
runs-on: ubuntu-latest
93-
steps:
94-
- name: checkout
95-
run: git clone "$GITHUB_SERVER_URL"/"$GITHUB_REPOSITORY" "$GITHUB_WORKSPACE" && cd "$GITHUB_WORKSPACE" && git checkout "$GITHUB_SHA"
96-
- name: push-provider-split
97-
uses: tcarrio/git-filter-repo-docker-action@v1
98-
with:
99-
privateKey: ${{ secrets.SSH_PRIVATE_KEY }}
100-
targetOrg: open-feature-php
101-
targetRepo: go-feature-flag-provider
102-
targetBranch: refs/tags/${{ github.event.release.tag_name }}
103-
filterArguments: '--subdirectory-filter providers/GoFeatureFlag/ --force'
67+
targetRepo: ${{ matrix.config[1] }}-${{ matrix.config[0] }}
68+
targetBranch: ${{ steps.targetRef.outputs.result }}
69+
tagFilter: ^open-feature/${{ matrix.config[1] }}-
70+
filterArguments: |
71+
--subdirectory-filter "${{matrix.config[0] }}s/${{ matrix.config[2] }}/" \
72+
--tag-rename "open-feature/${{ matrix.config[1] }}-${{ matrix.config[0] }}-:" \
73+
--force

.gitsplit.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.release-please-manifest.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"hooks/DDTrace": "0.2.0",
3-
"hooks/OpenTelemetry": "0.2.0",
4-
"hooks/Validators": "0.2.0",
5-
"providers/CloudBees": "0.3.0",
6-
"providers/Flagd": "0.4.0",
7-
"providers/Split": "0.3.0",
8-
"providers/GoFeatureFlag": "0.1.0"
2+
"hooks/DDTrace": "1.0.0",
3+
"hooks/OpenTelemetry": "1.0.0",
4+
"hooks/Validators": "1.0.0",
5+
"providers/CloudBees": "1.0.0",
6+
"providers/Flagd": "1.0.0",
7+
"providers/Split": "1.0.0",
8+
"providers/GoFeatureFlag": "1.0.0"
99
}

release-please-config.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,31 @@
88
"packages": {
99
"hooks/DDTrace": {
1010
"package-name": "open-feature/dd-trace-hook",
11-
"release-as": "0.2.0"
11+
"release-as": "1.0.0"
1212
},
1313
"hooks/OpenTelemetry": {
1414
"package-name": "open-feature/otel-hook",
15-
"release-as": "0.2.0"
15+
"release-as": "1.0.0"
1616
},
1717
"hooks/Validators": {
1818
"package-name": "open-feature/validators-hook",
19-
"release-as": "0.2.0"
19+
"release-as": "1.0.0"
2020
},
2121
"providers/CloudBees": {
2222
"package-name": "open-feature/cloudbees-provider",
23-
"release-as": "0.3.0"
23+
"release-as": "1.0.0"
2424
},
2525
"providers/Flagd": {
2626
"package-name": "open-feature/flagd-provider",
27-
"release-as": "0.4.0"
27+
"release-as": "1.0.0"
2828
},
2929
"providers/Split": {
3030
"package-name": "open-feature/split-provider",
31-
"release-as": "0.3.0"
31+
"release-as": "1.0.0"
3232
},
3333
"providers/GoFeatureFlag": {
3434
"package-name": "open-feature/go-feature-flag-provider",
35-
"release-as": "0.1.0"
35+
"release-as": "1.0.0"
3636
}
3737
}
3838
}

0 commit comments

Comments
 (0)