1515 pull-requests : write
1616
1717 steps :
18- - name : Checkout code
18+ - name : Checkout Code
1919 uses : actions/checkout@v3
2020
2121 - name : Setup Node.js
@@ -24,11 +24,21 @@ jobs:
2424 node-version : 18
2525 cache : npm
2626
27- - name : Install dependencies
27+ - name : Install Dependencies
2828 run : npm ci
2929
3030 - name : Build
3131 run : npm run build
32+ env :
33+ TYPESENSE_HOST : ${{ secrets.TYPESENSE_HOST }}
34+ TYPESENSE_PORT : 443
35+ TYPESENSE_PROTOCOL : https
36+ TYPESENSE_SEARCH_API_KEY : ${{ secrets.TYPESENSE_SEARCH_API_KEY }}
37+
38+ - name : Write Deployment Marker
39+ if : github.ref == 'refs/heads/master'
40+ run : |
41+ printf '{"deploymentId":"%s"}\n' '${{ github.run_id }}' > build/deployment.json
3242
3343 - name : Publish to Cloudflare Pages
3444 id : cloudflare-pages
3949 projectName : topper-docs
4050 directory : build
4151
42- - name : Add comment
52+ - name : Wait for Deployment
53+ if : github.ref == 'refs/heads/master'
54+ run : |
55+ for attempt in $(seq 1 30); do
56+ if curl -fsS "https://docs.topperpay.com/deployment.json?run=${{ github.run_id }}&attempt=$attempt" | grep -F '"deploymentId":"${{ github.run_id }}"' > /dev/null; then
57+ exit 0
58+ fi
59+
60+ echo "Site not updated yet, retrying ($attempt/30)."
61+ sleep 10
62+ done
63+
64+ echo "Timed out waiting for https://docs.topperpay.com/deployment.json to serve deploymentId ${{ github.run_id }}."
65+ exit 1
66+
67+ - name : Index Docs in Typesense
68+ if : github.ref == 'refs/heads/master'
69+ run : npm run index
70+ env :
71+ TYPESENSE_API_KEY : ${{ secrets.TYPESENSE_API_KEY }}
72+ TYPESENSE_HOST : ${{ secrets.TYPESENSE_HOST }}
73+ TYPESENSE_PORT : 443
74+ TYPESENSE_PROTOCOL : https
75+
76+ - name : Add Comment
4377 uses : mshick/add-pr-comment@v2
4478 with :
4579 message : |
4882 | Name | Link |
4983 |------ | ---- |
5084 | <span aria-hidden="true">🔨</span> Commit SHA | ${{ github.sha }} |
51- | <span aria-hidden="true">🔍</span> Deploy log | ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
85+ | <span aria-hidden="true">🔍</span> Deploy Log | ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
5286 | <span aria-hidden="true">🚀</span> Preview URL | [${{ steps.cloudflare-pages.outputs.url }}](${{ steps.cloudflare-pages.outputs.url }}) |
0 commit comments