forked from aws-otel/aws-otel.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (67 loc) · 2.14 KB
/
main.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
name: Gatsby Publish
env:
DELTA_THRESHOLD: .90
on:
push:
branches:
- main
jobs:
publish-smoke-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.5.3
- uses: enriikke/gatsby-gh-pages-action@v2
env:
GH_API_KEY: ${{ secrets.GITHUB_TOKEN }}
with:
access-token: ${{ secrets.demo }}
deploy-branch: smoke-test
verify-smoke-test:
runs-on: ubuntu-latest
needs: publish-smoke-test
steps:
- name: Checkout Smoke Test Branch
uses: actions/checkout@v3.5.3
with:
path: smoke-test
ref: smoke-test
- name: Calculate total lines in smoke-test branch
run: |
export ST_LC=$(find ./smoke-test -type f -print0 | wc -l --files0=- | tail -n 1 | cut -d ' ' -f 1)
echo $ST_LC
echo "SMOKE_TEST_LINE_COUNT=$ST_LC" >> $GITHUB_ENV
- name: Checkout Published Branch
uses: actions/checkout@v3.5.3
with:
path: published
ref: gh-pages
- name: Calculate total lines in published branch
run: |
export PUB_LC=$(find ./published -type f -print0 | wc -l --files0=- | tail -n 1 | cut -d ' ' -f 1)
echo $PUB_LC
echo "PUBLISHED_LINE_COUNT=$PUB_LC" >> $GITHUB_ENV
- name: Generate percentile diff
run: |
export PERCENTILE_DIFF=$(bc<<<"scale=2;${{ env.SMOKE_TEST_LINE_COUNT}} / ${{ env.PUBLISHED_LINE_COUNT }}")
echo $PERCENTILE_DIFF
if [ 1 -eq $(bc<<<"$PERCENTILE_DIFF < ${{ env.DELTA_THRESHOLD }}") ]; then
exit 1
else
exit 0
fi
publish-live:
needs: verify-smoke-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.5.3
with:
ref: gh-pages
- name: merge commit push
env:
GITHUB_TOKEN: ${{ secrets.demo }}
run: |
git config --global user.name 'Gatsby Publish Workflow'
git config --global user.email 'gatsby-publish-workflow@users.noreply.github.com'
git fetch --all
git reset --hard origin/smoke-test
git push -f origin gh-pages