-
Notifications
You must be signed in to change notification settings - Fork 1
84 lines (73 loc) · 2.69 KB
/
Copy pathdeploy.yml
File metadata and controls
84 lines (73 loc) · 2.69 KB
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
name: Deploy to Production
on:
push:
branches: [main]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20.19.6"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Type check
run: npm run typecheck
- name: Test MCP + Webhook server
run: |
cd mcp-server
npm install
npm test
- name: Generate API docs
run: npm run gen-api
- name: Build
run: npm run build
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Trigger DigitalOcean App Platform Deployment
id: deploy
run: |
echo "Deploying to production environment..."
resp=$(curl -sS -X POST \
-H "Authorization: Bearer ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}" \
-H "Content-Type: application/json" \
"https://api.digitalocean.com/v2/apps/${{ secrets.DO_APP_ID_PROD }}/deployments" \
--fail-with-body)
id=$(echo "$resp" | jq -r '.deployment.id')
echo "Triggered deployment $id"
echo "deployment_id=$id" >> "$GITHUB_OUTPUT"
# Wait for the deployment to go live, then refresh the MCP index so search
# reflects the just-published docs (the mcp loads the index from the public
# URL at startup, which during a deploy is still the previous build).
# Best-effort: this step must never fail the workflow.
- name: Wait for deploy, then refresh MCP index
run: |
app="${{ secrets.DO_APP_ID_PROD }}"
id="${{ steps.deploy.outputs.deployment_id }}"
if [ -z "$id" ] || [ "$id" = "null" ]; then
echo "No deployment id — skipping refresh."; exit 0
fi
for i in $(seq 1 60); do
phase=$(curl -sS \
-H "Authorization: Bearer ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}" \
"https://api.digitalocean.com/v2/apps/$app/deployments/$id" \
| jq -r '.deployment.phase')
echo "deployment $id phase=$phase"
case "$phase" in
ACTIVE)
echo "Deployment live — refreshing MCP index..."
curl -sS -X POST https://docs.ottu.com/mcp/refresh && echo " MCP index refreshed"
exit 0 ;;
ERROR|CANCELED|SUPERSEDED)
echo "Deployment ended as $phase — skipping refresh."; exit 0 ;;
esac
sleep 15
done
echo "Timed out waiting for ACTIVE — skipping refresh."; exit 0