Repository navigation
69 lines (62 loc) · 2.54 KB
/
Copy pathsplit-modules.yml
File metadata and controls
69 lines (62 loc) · 2.54 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
name: Split modules to standalone repos
on:
push:
branches: [main]
jobs:
split:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- dir: frontend
repo: Shadowfit/frontend
- dir: backend
repo: Shadowfit/backend
- dir: ai-server
repo: Shadowfit/ai-server
steps:
- name: Checkout with full history
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Check for changes in ${{ matrix.dir }}
id: changes
run: |
BEFORE="${{ github.event.before }}"
EXTRA_PATHS=""
if [ "${{ matrix.dir }}" = "backend" ]; then
EXTRA_PATHS="docker-compose.yml mysql"
fi
if [ -z "$BEFORE" ] || ! git cat-file -e "$BEFORE" 2>/dev/null; then
echo "changed=true" >> "$GITHUB_OUTPUT"
elif git diff --quiet "$BEFORE" "${{ github.sha }}" -- "${{ matrix.dir }}" $EXTRA_PATHS; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Split ${{ matrix.dir }} history
if: steps.changes.outputs.changed == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git subtree split --prefix=${{ matrix.dir }} -b split-${{ matrix.dir }}
- name: Bundle docker-compose.yml + mysql into backend split
if: steps.changes.outputs.changed == 'true' && matrix.dir == 'backend'
run: |
git checkout split-backend
git checkout ${{ github.sha }} -- docker-compose.yml mysql
git add docker-compose.yml mysql
git commit -m "chore: 모노레포 루트 docker-compose.yml + mysql 동기화"
- name: Preserve Shadowfit/backend's own README.md
if: steps.changes.outputs.changed == 'true' && matrix.dir == 'backend'
run: |
git checkout split-backend
curl -sf -o README.md "https://raw.githubusercontent.com/${{ matrix.repo }}/main/README.md" || true
git add README.md
git diff --cached --quiet || git commit -m "chore: README는 타겟 레포 기준 유지"
- name: Push to ${{ matrix.repo }}
if: steps.changes.outputs.changed == 'true'
run: |
git push "https://x-access-token:${{ secrets.SPLIT_PUSH_TOKEN }}@github.com/${{ matrix.repo }}.git" "split-${{ matrix.dir }}:main" --force