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,20 @@ 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+ run : |
40+ printf '{"deploymentId":"%s"}\n' '${{ github.run_id }}' > build/deployment.json
3241
3342 - name : Publish to Cloudflare Pages
3443 id : cloudflare-pages
3948 projectName : topper-docs
4049 directory : build
4150
42- - name : Add comment
51+ - name : Wait for Deployment
52+ if : github.ref == 'refs/heads/master'
53+ run : |
54+ for attempt in $(seq 1 30); do
55+ if curl -fsS "https://docs.topperpay.com/deployment.json?run=${{ github.run_id }}&attempt=$attempt" | grep -F '"deploymentId":"${{ github.run_id }}"' > /dev/null; then
56+ exit 0
57+ fi
58+
59+ echo "Site not updated yet, retrying ($attempt/30)."
60+ sleep 10
61+ done
62+
63+ echo "Timed out waiting for https://docs.topperpay.com/deployment.json to serve deploymentId ${{ github.run_id }}."
64+ exit 1
65+
66+ - name : Index Docs in Typesense
67+ if : github.ref == 'refs/heads/master'
68+ run : npm run index
69+ env :
70+ TYPESENSE_API_KEY : ${{ secrets.TYPESENSE_API_KEY }}
71+ TYPESENSE_HOST : ${{ secrets.TYPESENSE_HOST }}
72+ TYPESENSE_PORT : 443
73+ TYPESENSE_PROTOCOL : https
74+
75+ - name : Add Comment
4376 uses : mshick/add-pr-comment@v2
4477 with :
4578 message : |
4881 | Name | Link |
4982 |------ | ---- |
5083 | <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 }} |
84+ | <span aria-hidden="true">🔍</span> Deploy Log | ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
5285 | <span aria-hidden="true">🚀</span> Preview URL | [${{ steps.cloudflare-pages.outputs.url }}](${{ steps.cloudflare-pages.outputs.url }}) |
0 commit comments