-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (106 loc) · 4.09 KB
/
split.yml
File metadata and controls
116 lines (106 loc) · 4.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Packages Split
on:
push:
branches:
- master
tags:
- '*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to split (leave empty for branch-only split)'
required: false
type: string
jobs:
packages_split:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package:
- local_path: 'src/contracts'
split_repository: 'PHP-CA-contracts'
tag_suffix: ''
- local_path: 'src/library'
split_repository: 'PHP-CA-library'
tag_suffix: ''
- local_path: 'src/config-manager'
split_repository: 'PHP-CA-config-manager'
tag_suffix: ''
- local_path: 'src/cli'
split_repository: 'CLI-PHP-CA'
tag_suffix: '-src'
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@v3
with:
app-id: ${{ secrets.SPLIT_APP_ID }}
private-key: ${{ secrets.SPLIT_APP_PRIVATE_KEY }}
owner: kduma-OSS-splits
- name: Initialize split repo if empty
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
REPO="kduma-OSS-splits/${{ matrix.package.split_repository }}"
TMPDIR=$(mktemp -d)
git clone "https://x-access-token:${GH_TOKEN}@github.com/$REPO.git" "$TMPDIR" 2>&1 || true
if ! git -C "$TMPDIR" rev-parse HEAD >/dev/null 2>&1; then
echo "Repository $REPO is empty, initializing with empty commit on master..."
git -C "$TMPDIR" checkout -b master
git -C "$TMPDIR" config user.name "github-actions[bot]"
git -C "$TMPDIR" config user.email "github-actions[bot]@users.noreply.github.com"
git -C "$TMPDIR" commit --allow-empty -m "Initial commit"
git -C "$TMPDIR" push origin master
echo "Initialized $REPO with master branch"
else
echo "Repository $REPO already has commits, skipping initialization"
fi
rm -rf "$TMPDIR"
- name: Resolve tag
id: resolve-tag
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ inputs.tag }}" ]]; then
SOURCE_TAG="${{ inputs.tag }}"
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
SOURCE_TAG="${{ github.ref_name }}"
else
SOURCE_TAG=""
fi
echo "source_tag=${SOURCE_TAG}" >> "$GITHUB_OUTPUT"
if [[ -n "$SOURCE_TAG" ]]; then
echo "split_tag=${SOURCE_TAG}${{ matrix.package.tag_suffix }}" >> "$GITHUB_OUTPUT"
else
echo "split_tag=" >> "$GITHUB_OUTPUT"
fi
- name: Checkout tag
if: steps.resolve-tag.outputs.source_tag != ''
run: git checkout "refs/tags/${{ steps.resolve-tag.outputs.source_tag }}"
- name: Split (no tag)
if: steps.resolve-tag.outputs.split_tag == ''
uses: danharrin/monorepo-split-github-action@v2.4.0
env:
PAT: x-access-token:${{ steps.app-token.outputs.token }}
with:
package_directory: ${{ matrix.package.local_path }}
repository_organization: 'kduma-OSS-splits'
repository_name: ${{ matrix.package.split_repository }}
branch: 'master'
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
- name: Split (with tag)
if: steps.resolve-tag.outputs.split_tag != ''
uses: danharrin/monorepo-split-github-action@v2.4.0
env:
PAT: x-access-token:${{ steps.app-token.outputs.token }}
with:
tag: ${{ steps.resolve-tag.outputs.split_tag }}
package_directory: ${{ matrix.package.local_path }}
repository_organization: 'kduma-OSS-splits'
repository_name: ${{ matrix.package.split_repository }}
branch: 'master'
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'