Skip to content

ci: use new git-filter-repo based action with tag filtering support for splitting monorepo to PHP packages #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
}
}
Loading