-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (100 loc) · 3.86 KB
/
Copy pathphp-split.yml
File metadata and controls
108 lines (100 loc) · 3.86 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
name: Sync / PHP Split Repository
on:
push:
branches: [master]
paths:
- 'implementations/php/pcf/**'
- 'implementations/php/pcf-sig/**'
- '.github/workflows/php-split.yml'
workflow_dispatch:
inputs:
tag:
description: 'Tag to split (leave empty for branch-only split)'
required: false
type: string
workflow_call:
inputs:
tag:
description: 'Tag to split (leave empty for branch-only split)'
required: false
type: string
default: ''
jobs:
split:
name: split ${{ matrix.package.dir }} → kduma-OSS-splits/${{ matrix.package.repo }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package:
- { dir: 'implementations/php/pcf', repo: 'PHP-PCF-lib' }
- { dir: 'implementations/php/pcf-sig', repo: 'PHP-PCF-SIG-lib' }
- { dir: 'implementations/php/pcf-dcp', repo: 'PHP-PCF-DCP-lib' }
steps:
- uses: actions/checkout@v4
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: |
set -euo pipefail
REPO="kduma-OSS-splits/${{ matrix.package.repo }}"
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 master with empty commit..."
git -C "$TMPDIR" checkout -b master
git -C "$TMPDIR" config user.name "github-actions[bot]"
git -C "$TMPDIR" config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git -C "$TMPDIR" commit --allow-empty -m "Initial commit"
git -C "$TMPDIR" push origin master
else
echo "Repository $REPO already has commits, skipping initialization"
fi
rm -rf "$TMPDIR"
- name: Resolve tag
id: resolve-tag
run: |
if [[ -n "${{ inputs.tag }}" ]]; then
echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT"
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
else
echo "tag=" >> "$GITHUB_OUTPUT"
fi
- name: Checkout tag
if: steps.resolve-tag.outputs.tag != ''
run: git checkout "refs/tags/${{ steps.resolve-tag.outputs.tag }}"
- name: Split (no tag)
if: steps.resolve-tag.outputs.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.dir }}
repository_organization: 'kduma-OSS-splits'
repository_name: ${{ matrix.package.repo }}
branch: 'master'
user_name: 'github-actions[bot]'
user_email: '41898282+github-actions[bot]@users.noreply.github.com'
- name: Split (with tag)
if: steps.resolve-tag.outputs.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.tag }}
package_directory: ${{ matrix.package.dir }}
repository_organization: 'kduma-OSS-splits'
repository_name: ${{ matrix.package.repo }}
branch: 'master'
user_name: 'github-actions[bot]'
user_email: '41898282+github-actions[bot]@users.noreply.github.com'