|
1 | 1 | name: Gatsby Publish
|
2 | 2 |
|
| 3 | +env: |
| 4 | + DELTA_THRESHOLD: .90 |
| 5 | + |
3 | 6 | on:
|
4 | 7 | push:
|
5 | 8 | branches:
|
6 | 9 | - main
|
| 10 | + |
7 | 11 |
|
8 | 12 | jobs:
|
9 |
| - build: |
| 13 | + publish-smoke-test: |
10 | 14 | runs-on: ubuntu-latest
|
11 | 15 | steps:
|
12 | 16 | - uses: actions/checkout@v1
|
|
15 | 19 | GH_API_KEY: ${{ secrets.GITHUB_TOKEN }}
|
16 | 20 | with:
|
17 | 21 | access-token: ${{ secrets.demo }}
|
18 |
| - deploy-branch: gh-pages |
19 |
| -# gatsby-args: --prefix-paths |
| 22 | + deploy-branch: smoke-test |
| 23 | + verify-smoke-test: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + needs: publish-smoke-test |
| 26 | + steps: |
| 27 | + - name: Checkout Smoke Test Branch |
| 28 | + uses: actions/checkout@v3 |
| 29 | + with: |
| 30 | + path: smoke-test |
| 31 | + ref: smoke-test |
| 32 | + - name: Calculate total lines in smoke-test branch |
| 33 | + run: | |
| 34 | + export ST_LC=$(find ./smoke-test -type f -print0 | wc -l --files0=- | tail -n 1 | cut -d ' ' -f 1) |
| 35 | + echo $ST_LC |
| 36 | + echo "SMOKE_TEST_LINE_COUNT=$ST_LC" >> $GITHUB_ENV |
| 37 | + - name: Checkout Published Branch |
| 38 | + uses: actions/checkout@v3 |
| 39 | + with: |
| 40 | + path: published |
| 41 | + ref: gh-pages |
| 42 | + - name: Calculate total lines in published branch |
| 43 | + run: | |
| 44 | + export PUB_LC=$(find ./published -type f -print0 | wc -l --files0=- | tail -n 1 | cut -d ' ' -f 1) |
| 45 | + echo $PUB_LC |
| 46 | + echo "PUBLISHED_LINE_COUNT=$PUB_LC" >> $GITHUB_ENV |
| 47 | + - name: Generate percentile diff |
| 48 | + run: | |
| 49 | + export PERCENTILE_DIFF=$(bc<<<"scale=2;${{ env.SMOKE_TEST_LINE_COUNT}} / ${{ env.PUBLISHED_LINE_COUNT }}") |
| 50 | + echo $PERCENTILE_DIFF |
| 51 | + if [ 1 -eq $(bc<<<"$PERCENTILE_DIFF < ${{ env.DELTA_THRESHOLD }}") ]; then |
| 52 | + exit 1 |
| 53 | + else |
| 54 | + exit 0 |
| 55 | + fi |
| 56 | +
|
| 57 | + publish-live: |
| 58 | + needs: verify-smoke-test |
| 59 | + runs-on: ubuntu-latest |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@v3 |
| 62 | + with: |
| 63 | + ref: gh-pages |
| 64 | + - name: merge commit push |
| 65 | + env: |
| 66 | + GITHUB_TOKEN: ${{ secrets.demo }} |
| 67 | + run: | |
| 68 | + git config --global user.name 'Gatsby Publish Workflow' |
| 69 | + git config --global user.email '[email protected]' |
| 70 | + git fetch --all |
| 71 | + git reset --hard origin/smoke-test |
| 72 | + git push -f origin gh-pages |
0 commit comments