-
Notifications
You must be signed in to change notification settings - Fork 31
149 lines (146 loc) · 4.75 KB
/
deploy.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
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
147
148
name: Yarn build and Publish to another repo
on:
workflow_dispatch:
repository_dispatch:
types: [dependency]
push:
branches: [master]
pull_request:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Prepare static
run: |
git clone https://github.com/mirrorz-org/mirrorz-json-legacy.git static/json/json-legacy
mv static/json/json-legacy/data static/json/legacy
rm -rf static/json/json-legacy
git clone https://github.com/mirrorz-org/mirrorz-json-site.git static/json/site
- name: Prepare parser, config, i18n, oh-my-mirrorz
run: |
git clone https://github.com/mirrorz-org/mirrorz-parser.git src/parser
git clone https://github.com/mirrorz-org/mirrorz-config.git src/config
git clone https://github.com/mirrorz-org/mirrorz-i18n.git src/i18n
yarn mirrorz_env
git clone https://github.com/mirrorz-org/oh-my-mirrorz.git scripts/oh-my-mirrorz
- name: Prepare legacy
run: |
git clone https://github.com/mirrorz-org/mirrorz-legacy.git legacy
yarn legacy_env
- name: Install dependencies
run: yarn --frozen-lockfile
- name: Install legacy dependencies
run: |
cd legacy
yarn --frozen-lockfile
cd ..
- name: Build
run: |
yarn build
yarn legacy_build
yarn ohmymirrorz_build
mkdir -p drop
tar -czf drop/dist.tar.gz dist
- name: Upload dist package as artifact
uses: actions/upload-artifact@v3
with:
name: dist
path: drop/dist.tar.gz
retention-days: 3
screenshots:
name: Visual diff
if: ${{ false }} # TODO: disable for now. Should provide a mock env
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '14'
- name: Install dependencies
run: |
yarn --frozen-lockfile
npx playwright install-deps
npx playwright install
- name: Download dist package
uses: actions/download-artifact@v3
with:
name: dist
- name: Unzip dist package
run: |
tar xzf dist.tar.gz
- name: Update snapshot baseline
if: ${{ github.ref == 'refs/heads/master' }}
run: |
yarn test --update-snapshots
- name: Upload screenshot baseline as artifacts
if: ${{ github.ref == 'refs/heads/master' }}
uses: actions/upload-artifact@v3
with:
name: screenshot-baseline
path: |
tests/*-snapshots
- name: Download baseline and take screenshots
if: ${{ github.ref != 'refs/heads/master' }}
run: |
yarn download-snapshot-baseline snapshot-baseline.zip
unzip -o snapshot-baseline.zip -d tests
yarn test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload screenshot differences as artifacts
if: ${{ github.ref != 'refs/heads/master' && always() }}
uses: actions/upload-artifact@v3
with:
name: screenshots
path: |
tests/*-snapshots
test-results
retention-days: 3
deploy:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' }}
needs:
- build
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Download dist package
uses: actions/download-artifact@v3
with:
name: dist
- name: Commit and publish
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
PUBLISH_REPOSITORY: ${{ secrets.PUBLISH_REPOSITORY }}
run: |
tar xzf dist.tar.gz
remote_repo="https://x-access-token:${ACCESS_TOKEN}@github.com/${PUBLISH_REPOSITORY}.git"
remote_branch="master"
git_commit_id=$(git rev-parse --short HEAD)
mkdir _site_remote && cd _site_remote
git init
git config user.name "Mirrorz Bot"
git config user.email "[email protected]"
git remote add origin $remote_repo
git pull origin $remote_branch
git rm -rf .
git clean -fxd
cp -ar ../dist/* ./
touch .nojekyll
git add .
git commit -m "Github Action auto build for https://github.com/tuna/mirrorz/commit/${git_commit_id}" --allow-empty
git push -u origin $remote_branch