-
Notifications
You must be signed in to change notification settings - Fork 6
57 lines (52 loc) · 1.68 KB
/
sync-to-web.yml
File metadata and controls
57 lines (52 loc) · 1.68 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
name: Sync code from main to web
on:
push:
branches: [main]
paths-ignore:
- 'data/**'
- 'gitforge.config.json'
permissions:
contents: write
actions: write
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Merge main into web (preserving web's data)
run: |
git fetch origin
if git ls-remote --exit-code --heads origin web; then
git checkout web
git merge origin/main --no-ff --no-commit || true
# Always restore web's personal files
git checkout HEAD -- data/ gitforge.config.json
git diff --cached --quiet || git commit -m "Sync code from main"
git push origin web
echo "pushed=true" >> "$GITHUB_OUTPUT"
else
echo "web branch not found — creating it from main"
git checkout -b web origin/main
git push origin web
echo "Created web branch from main."
echo "pushed=true" >> "$GITHUB_OUTPUT"
fi
id: sync
- name: Trigger deploy
if: steps.sync.outputs.pushed == 'true'
uses: actions/github-script@v7
with:
script: |
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'deploy.yml',
ref: 'web'
})