Repository navigation
66 lines (58 loc) · 2.35 KB
/
Copy pathweb-sync.yml
File metadata and controls
66 lines (58 loc) · 2.35 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
name: Web sync
# Keeps the web branch (the browser app published on Vercel, with the phone viewer) up to date:
# every push to main is merged into web, then web-deploy.yml publishes it. The web branch only
# adds files of its own (the viewer in apps/draftcraft-web/src/viewer, phone.rs, viewer.html,
# vercel.json, web-deploy.yml) and a few lines in apps/draftcraft-web, so the merge normally
# needs no hand. When it does, the run fails and an issue says which files conflict; merge main
# into web by hand and push.
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: write
actions: write
issues: write
concurrency:
group: web-sync
cancel-in-progress: false
jobs:
sync:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
with:
ref: web
fetch-depth: 0
- name: Merge main into web
id: merge
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git fetch origin main
if git merge --no-edit -m "Merge main into web" origin/main; then
echo "Merged main into web." >> "$GITHUB_STEP_SUMMARY"
else
conflicts=$(git diff --name-only --diff-filter=U | tr '\n' ' ')
git merge --abort
echo "conflicts=$conflicts" >> "$GITHUB_OUTPUT"
echo "::error::Merging main into web conflicts in: $conflicts"
exit 1
fi
- name: Push web
run: git push origin HEAD:web
- name: Publish
env:
GH_TOKEN: ${{ github.token }}
run: gh workflow run web-deploy.yml --ref web
- name: Report a conflict
if: failure() && steps.merge.outputs.conflicts != ''
env:
GH_TOKEN: ${{ github.token }}
CONFLICTS: ${{ steps.merge.outputs.conflicts }}
run: |
title="Web sync: main does not merge into web"
if [ -z "$(gh issue list --state open --search "$title in:title" --json number --jq '.[].number')" ]; then
gh issue create --title "$title" --body "Merging main ($GITHUB_SHA) into the web branch conflicts in: $CONFLICTS. Merge main into web by hand and push; the next push to main syncs again. Run: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
fi