This repository was archived by the owner on Aug 25, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
146 lines (133 loc) · 4.56 KB
/
Copy pathphp-split-sync.yml
File metadata and controls
146 lines (133 loc) · 4.56 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: PHP Split Repo Sync
on:
push:
tags:
- v*
workflow_dispatch:
inputs:
target:
description: Which package to sync
required: false
default: all
type: choice
options:
- all
- core
- admin
sync_mode:
description: Sync branch or tag
required: false
default: branch
type: choice
options:
- branch
- tag
tag_name:
description: Tag name to mirror when sync_mode=tag
required: false
type: string
permissions:
contents: read
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
concurrency:
group: php-split-sync-${{ github.ref }}
cancel-in-progress: false
jobs:
sync:
name: Sync PHP split repo (${{ matrix.target }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: core
prefix: packages/sdk/php/packages/core
default_repo: edge-base/edgebase-php-core
- target: admin
prefix: packages/sdk/php/packages/admin
default_repo: edge-base/edgebase-php-admin
steps:
- name: Check split push token
env:
EDGEBASE_SPLIT_PUSH_TOKEN: ${{ secrets.EDGEBASE_SPLIT_PUSH_TOKEN }}
run: |
if [[ -z "${EDGEBASE_SPLIT_PUSH_TOKEN}" ]]; then
echo "::error::Missing secret EDGEBASE_SPLIT_PUSH_TOKEN."
echo "::error::Create a PAT or GitHub App token with contents:write access to the split repositories."
exit 1
fi
- name: Checkout source repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.sync_mode == 'tag' && github.event.inputs.tag_name || github.ref }}
- name: Configure sync target
id: config
env:
INPUT_TARGET: ${{ github.event.inputs.target }}
INPUT_SYNC_MODE: ${{ github.event.inputs.sync_mode }}
INPUT_TAG_NAME: ${{ github.event.inputs.tag_name }}
TARGET: ${{ matrix.target }}
DEFAULT_REPO: ${{ matrix.default_repo }}
PHP_CORE_SPLIT_REPO: ${{ vars.PHP_CORE_SPLIT_REPO }}
PHP_ADMIN_SPLIT_REPO: ${{ vars.PHP_ADMIN_SPLIT_REPO }}
GITHUB_REF_NAME: ${{ github.ref_name }}
GITHUB_REF_TYPE: ${{ github.ref_type }}
GITHUB_EVENT_NAME: ${{ github.event_name }}
run: |
set -euo pipefail
requested_target="${INPUT_TARGET:-all}"
if [[ "$requested_target" != "all" && "$requested_target" != "$TARGET" ]]; then
echo "enabled=false" >> "$GITHUB_OUTPUT"
exit 0
fi
case "$TARGET" in
core)
destination_repo="${PHP_CORE_SPLIT_REPO:-$DEFAULT_REPO}"
;;
admin)
destination_repo="${PHP_ADMIN_SPLIT_REPO:-$DEFAULT_REPO}"
;;
*)
echo "::error::Unsupported target ${TARGET}"
exit 1
;;
esac
if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
sync_mode="${INPUT_SYNC_MODE:-branch}"
if [[ "$sync_mode" == "tag" ]]; then
ref_name="${INPUT_TAG_NAME:-}"
if [[ -z "$ref_name" ]]; then
echo "::error::workflow_dispatch tag sync requires tag_name."
exit 1
fi
else
ref_name="main"
fi
else
if [[ "$GITHUB_REF_TYPE" == "tag" ]]; then
sync_mode="tag"
ref_name="$GITHUB_REF_NAME"
else
sync_mode="branch"
ref_name="main"
fi
fi
echo "enabled=true" >> "$GITHUB_OUTPUT"
echo "destination_repo=$destination_repo" >> "$GITHUB_OUTPUT"
echo "sync_mode=$sync_mode" >> "$GITHUB_OUTPUT"
echo "ref_name=$ref_name" >> "$GITHUB_OUTPUT"
- name: Sync split repository
if: steps.config.outputs.enabled == 'true'
env:
EDGEBASE_SPLIT_PUSH_TOKEN: ${{ secrets.EDGEBASE_SPLIT_PUSH_TOKEN }}
run: |
chmod +x ./scripts/sync-php-split-repo.sh
./scripts/sync-php-split-repo.sh \
"${{ matrix.target }}" \
"${{ matrix.prefix }}" \
"${{ steps.config.outputs.destination_repo }}" \
"${{ steps.config.outputs.sync_mode }}" \
"${{ steps.config.outputs.ref_name }}"