Skip to content

Commit

Permalink
ci: use new git-filter-repo based action with tag filtering support f…
Browse files Browse the repository at this point in the history
…or 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]>
  • Loading branch information
tcarrio authored Sep 4, 2024
1 parent 9f1f9f9 commit fb4da77
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 133 deletions.
152 changes: 61 additions & 91 deletions .github/workflows/split_monorepo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,102 +2,72 @@ name: split-monorepo
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: 'Package tag'
type: string
required: true

jobs:
split-hook-dd-trace:
split-repositories:
runs-on: ubuntu-latest
strategy:
matrix:
# Structure of the config tuple is:
# 0: Type of package (e.g. open-feature/flagd-*provider*)
# 1: Name of package (sans-org-prefix e.g. open-feature/*flagd*-provider)
# 2: Name of subdirectory (e.g. providers/*Flagd*)
config:
- [hook, dd-trace, DDTrace]
- [hook, otel, OpenTelemetry]
- [hook, validator, Validators]
- [provider, cloudbees, CloudBees]
- [provider, flagd, Flagd]
- [provider, split, Split]
- [provider, go-feature-flag, GoFeatureFlag]
steps:
- name: Detect run requirement
id: shouldRun
run: |
input_ref="${{ github.event.release.tag_name }}"
if [ -z "$input_ref" ]; then
input_ref="${{ inputs.tag }}"
fi
result=0
if [[ "$inputRef" == open-feature/${{ matrix.config[1] }}-${{ matrix.config[0] }}-* ]]; then
result=1
fi
echo "::set-output name=result::${result}"
- name: checkout
run: git clone "$GITHUB_SERVER_URL"/"$GITHUB_REPOSITORY" "$GITHUB_WORKSPACE" && cd "$GITHUB_WORKSPACE" && git checkout "$GITHUB_SHA"
- name: push-hook-dd-trace
uses: tcarrio/git-filter-repo-docker-action@v1
if: ${{ steps.shouldRun.outputs.result == '1' }}
run: |
git clone "$GITHUB_SERVER_URL"/"$GITHUB_REPOSITORY" "$GITHUB_WORKSPACE"
cd "$GITHUB_WORKSPACE"
git checkout "$GITHUB_SHA"
- name: Replace string in GitHub Actions
if: ${{ steps.shouldRun.outputs.result == '1' }}
id: targetRef
run: |
input_ref="${{ github.event.release.tag_name }}"
if [ -z "$input_ref" ]; then
input_ref="${{ inputs.tag }}"
fi
if [ -n "$input_ref" ]; then
input_ref="refs/tags/$input_ref"
target_ref="$(echo -n "$input_ref"|sed 's#open-feature/${{ matrix.config[1] }}-${{ matrix.config[0] }}-##')"
fi
echo "::set-output name=result::${target_ref}"
- name: Filter and push package ${{ matrix.config[1] }}-${{ matrix.config[0] }}
if: ${{ steps.shouldRun.outputs.result == '1' }}
uses: tcarrio/[email protected]
with:
privateKey: ${{ secrets.SSH_PRIVATE_KEY }}
targetOrg: open-feature-php
targetRepo: dd-trace-hook
targetBranch: refs/tags/${{ github.event.release.tag_name }}
filterArguments: '--subdirectory-filter hooks/DDTrace/ --force'

split-hook-otel:
runs-on: ubuntu-latest
steps:
- name: checkout
run: git clone "$GITHUB_SERVER_URL"/"$GITHUB_REPOSITORY" "$GITHUB_WORKSPACE" && cd "$GITHUB_WORKSPACE" && git checkout "$GITHUB_SHA"
- name: push-hook-otel
uses: tcarrio/git-filter-repo-docker-action@v1
with:
privateKey: ${{ secrets.SSH_PRIVATE_KEY }}
targetOrg: open-feature-php
targetRepo: otel-hook
targetBranch: refs/tags/${{ github.event.release.tag_name }}
filterArguments: '--subdirectory-filter hooks/OpenTelemetry/ --force'

split-hook-validator:
runs-on: ubuntu-latest
steps:
- name: checkout
run: git clone "$GITHUB_SERVER_URL"/"$GITHUB_REPOSITORY" "$GITHUB_WORKSPACE" && cd "$GITHUB_WORKSPACE" && git checkout "$GITHUB_SHA"
- name: push-hook-validator
uses: tcarrio/git-filter-repo-docker-action@v1
with:
privateKey: ${{ secrets.SSH_PRIVATE_KEY }}
targetOrg: open-feature-php
targetRepo: validators-hook
targetBranch: refs/tags/${{ github.event.release.tag_name }}
filterArguments: '--subdirectory-filter hooks/Validators/ --force'

split-provider-cloudbees:
runs-on: ubuntu-latest
steps:
- name: checkout
run: git clone "$GITHUB_SERVER_URL"/"$GITHUB_REPOSITORY" "$GITHUB_WORKSPACE" && cd "$GITHUB_WORKSPACE" && git checkout "$GITHUB_SHA"
- name: push-provider-cloudbees
uses: tcarrio/git-filter-repo-docker-action@v1
with:
privateKey: ${{ secrets.SSH_PRIVATE_KEY }}
targetOrg: open-feature-php
targetRepo: cloudbees-provider
targetBranch: refs/tags/${{ github.event.release.tag_name }}
filterArguments: '--subdirectory-filter providers/CloudBees/ --force'

split-provider-flagd:
runs-on: ubuntu-latest
steps:
- name: checkout
run: git clone "$GITHUB_SERVER_URL"/"$GITHUB_REPOSITORY" "$GITHUB_WORKSPACE" && cd "$GITHUB_WORKSPACE" && git checkout "$GITHUB_SHA"
- name: push-provider-flagd
uses: tcarrio/git-filter-repo-docker-action@v1
with:
privateKey: ${{ secrets.SSH_PRIVATE_KEY }}
targetOrg: open-feature-php
targetRepo: flagd-provider
targetBranch: refs/tags/${{ github.event.release.tag_name }}
filterArguments: '--subdirectory-filter providers/Flagd/ --force'

split-provider-split:
runs-on: ubuntu-latest
steps:
- name: checkout
run: git clone "$GITHUB_SERVER_URL"/"$GITHUB_REPOSITORY" "$GITHUB_WORKSPACE" && cd "$GITHUB_WORKSPACE" && git checkout "$GITHUB_SHA"
- name: push-provider-split
uses: tcarrio/git-filter-repo-docker-action@v1
with:
privateKey: ${{ secrets.SSH_PRIVATE_KEY }}
targetOrg: open-feature-php
targetRepo: split-provider
targetBranch: refs/tags/${{ github.event.release.tag_name }}
filterArguments: '--subdirectory-filter providers/Split/ --force'

split-provider-go-feature-flag:
runs-on: ubuntu-latest
steps:
- name: checkout
run: git clone "$GITHUB_SERVER_URL"/"$GITHUB_REPOSITORY" "$GITHUB_WORKSPACE" && cd "$GITHUB_WORKSPACE" && git checkout "$GITHUB_SHA"
- name: push-provider-split
uses: tcarrio/git-filter-repo-docker-action@v1
with:
privateKey: ${{ secrets.SSH_PRIVATE_KEY }}
targetOrg: open-feature-php
targetRepo: go-feature-flag-provider
targetBranch: refs/tags/${{ github.event.release.tag_name }}
filterArguments: '--subdirectory-filter providers/GoFeatureFlag/ --force'
targetRepo: ${{ matrix.config[1] }}-${{ matrix.config[0] }}
targetBranch: ${{ steps.targetRef.outputs.result }}
tagFilter: ^open-feature/${{ matrix.config[1] }}-
filterArguments: |
--subdirectory-filter "${{matrix.config[0] }}s/${{ matrix.config[2] }}/" \
--tag-rename "open-feature/${{ matrix.config[1] }}-${{ matrix.config[0] }}-:" \
--force
28 changes: 0 additions & 28 deletions .gitsplit.yml

This file was deleted.

14 changes: 7 additions & 7 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"hooks/DDTrace": "0.2.0",
"hooks/OpenTelemetry": "0.2.0",
"hooks/Validators": "0.2.0",
"providers/CloudBees": "0.3.0",
"providers/Flagd": "0.4.0",
"providers/Split": "0.3.0",
"providers/GoFeatureFlag": "0.1.0"
"hooks/DDTrace": "1.0.0",
"hooks/OpenTelemetry": "1.0.0",
"hooks/Validators": "1.0.0",
"providers/CloudBees": "1.0.0",
"providers/Flagd": "1.0.0",
"providers/Split": "1.0.0",
"providers/GoFeatureFlag": "1.0.0"
}
14 changes: 7 additions & 7 deletions release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@
"packages": {
"hooks/DDTrace": {
"package-name": "open-feature/dd-trace-hook",
"release-as": "0.2.0"
"release-as": "1.0.0"
},
"hooks/OpenTelemetry": {
"package-name": "open-feature/otel-hook",
"release-as": "0.2.0"
"release-as": "1.0.0"
},
"hooks/Validators": {
"package-name": "open-feature/validators-hook",
"release-as": "0.2.0"
"release-as": "1.0.0"
},
"providers/CloudBees": {
"package-name": "open-feature/cloudbees-provider",
"release-as": "0.3.0"
"release-as": "1.0.0"
},
"providers/Flagd": {
"package-name": "open-feature/flagd-provider",
"release-as": "0.4.0"
"release-as": "1.0.0"
},
"providers/Split": {
"package-name": "open-feature/split-provider",
"release-as": "0.3.0"
"release-as": "1.0.0"
},
"providers/GoFeatureFlag": {
"package-name": "open-feature/go-feature-flag-provider",
"release-as": "0.1.0"
"release-as": "1.0.0"
}
}
}

0 comments on commit fb4da77

Please sign in to comment.