-
Notifications
You must be signed in to change notification settings - Fork 64
124 lines (124 loc) · 4.05 KB
/
build-preview.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
name: Build PR Preview
on:
pull_request:
branches: [main]
types:
- opened
- reopened
- synchronize
workflow_dispatch:
permissions:
contents: read
pages: write
pull-requests: write
id-token: write
checks: write
concurrency: preview-${{ github.ref }}
jobs:
deploy-preview:
runs-on: ubuntu-latest
steps:
- name: Use Node.js 18.16.1
uses: actions/setup-node@v3
with:
node-version: 18.16.1 #18.17.0 is buggy
- name: Checkout Main Branch 🛎️
uses: actions/checkout@v3
with:
ref: main
path: main
- name: Install and Build Main Branch 🔧
run: |
npm ci --include=dev
npm run build
npm run style
npm run shields
cp src/configs/config.aws.js src/config.js
working-directory: main
- name: Capture main branch usage statistics
id: main-stats
run: |
MAIN_STATS=$(node scripts/stats.js -j)
echo "MAIN_STATS<<EOF" >> $GITHUB_ENV
echo -e "$MAIN_STATS" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
working-directory: main
- name: Capture main branch sample clips
id: main-samples
run: |
npm start &
until nc -z localhost 1776; do sleep 1; done
npm run generate_samples
kill $(lsof -t -i:1776) 2>/dev/null || echo "No process found listening on port 1776."
mv samples ../samples-main
working-directory: main
- name: Checkout PR Branch 🛎️
uses: actions/checkout@v3
with:
path: pr-branch
- name: Install and Build PR Branch 🔧
# TODO: when we move shieldlib to its own repo, move shieldlib docs CI also
run: |
npm ci --include=dev
npm run build
npm run style
npm run shields
cp src/configs/config.aws.js src/config.js
mkdir -p dist/shield-docs
cp -r shieldlib/docs/* dist/shield-docs
working-directory: pr-branch
- name: Capture PR branch sample clips
id: pr-samples
run: |
npm start &
until nc -z localhost 1776; do sleep 1; done
npm run generate_samples
kill $(lsof -t -i:1776) 2>/dev/null || echo "No process found listening on port 1776."
mv samples ../samples-pr
mv dist ..
working-directory: pr-branch
- name: Upload Build artifact
uses: actions/upload-artifact@v3
with:
name: americana
path: dist/
- name: Capture PR branch usage statistics
id: pr-stats
run: |
PR_STATS=$(node scripts/stats.js -j)
echo "PR_STATS<<EOF" >> $GITHUB_ENV
echo -e "$PR_STATS" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
working-directory: pr-branch
- name: Compare Stats
id: compare-stats
run: |
mkdir -p ../pr
echo '${{ env.MAIN_STATS }}'
echo '${{ env.PR_STATS }}'
npm exec ts-node scripts/stats_compare '${{ env.MAIN_STATS }}' '${{ env.PR_STATS }}' > ../pr/stats-difference.md
working-directory: pr-branch
- name: Generate map diff sample clips
id: map-diff-samples
run: |
ls -l ../samples-main
ls -l ../samples-pr
./scripts/folder_diff.sh ../samples-main ../samples-pr
ls -l samples-diff
mv pr_preview-extra.md ../pr/
cat ../pr/pr_preview-extra.md
mv samples-diff ../dist/
working-directory: pr-branch
- name: Save PR artifacts
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_SHA: ${{ github.event.pull_request.head.sha }}
run: |
echo $PR_NUMBER > pr/pr_number
echo $PR_SHA > pr/pr_sha
echo "Saved PR# ${{ github.event.pull_request.number }}, SHA# ${{ github.event.pull_request.head.sha }} for upload"
- name: Upload PR artifacts
uses: actions/upload-artifact@v3
with:
name: pr_ci_artifacts
path: pr/