-
-
Notifications
You must be signed in to change notification settings - Fork 3
75 lines (70 loc) · 2.43 KB
/
shadow-repo.yml
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
name: Sync with shadow repo
on:
push:
branches-ignore:
- 'dependabot/**'
create:
delete:
pull_request:
types: [opened]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
jobs:
sync-branch:
name: Create/delete shadow branch
runs-on: ubuntu-latest
if: github.event.ref_type == 'branch'
steps:
- name: Clone shadow repo
uses: actions/checkout@v4
with:
repository: ${{ secrets.SHADOW_OWNER }}/${{ secrets.SHADOW_REPO }}
ssh-key: ${{ secrets.SHADOW_REPO_PRIVATE_KEY }}
ref: main
- name: Create branch on shadow repo
if: github.event_name == 'create'
run: git push origin main:${{ github.event.ref }}
- name: Delete branch on shadow repo
if: github.event_name == 'delete'
run: git push origin --delete ${{ github.event.ref }}
push-branch:
name: Push to shadow branch
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v4
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: yarn
- run: yarn install
- run: yarn build:prod
- name: Clone shadow repo
uses: actions/checkout@v4
with:
repository: ${{ secrets.SHADOW_OWNER }}/${{ secrets.SHADOW_REPO }}
ssh-key: ${{ secrets.SHADOW_REPO_PRIVATE_KEY }}
ref: ${{ github.ref_name }}
path: shadow-repo
- name: Push to shadow branch
run: |
cd shadow-repo
rm -rf ./*
cp -rT ../_site .
git config user.name github-actions
git config user.email github-actions@github.com
git add -A
git commit --allow-empty -m "Update from https://github.com/${{ github.repository }}/commit/${{ github.sha }}"
git push origin
diff-link:
name: Create comment to diff link
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.action == 'opened'
steps:
- uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.number }}
body: |
View diff of compiled files (may take a few minutes): https://github.com/${{ secrets.SHADOW_OWNER }}/${{ secrets.SHADOW_REPO }}/compare/${{ github.event.pull_request.base.ref }}..${{ github.event.pull_request.head.ref }}