-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (69 loc) · 2.76 KB
/
deploy.yml
File metadata and controls
85 lines (69 loc) · 2.76 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
85
name: Deploy to DigitalOcean
on:
workflow_dispatch:
inputs:
environment:
description: 'Environment to deploy to'
required: true
default: 'production'
type: choice
options:
- production
env:
APP_ID: 4d1674ef-bfba-4fd3-9a97-943fa02c1f70 # Fixed app ID
jobs:
deploy:
name: Deploy to DigitalOcean App Platform
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Deploy to DigitalOcean
run: |
echo "Deploying to app ID: ${{ env.APP_ID }}"
# Update the app with the spec containing encrypted values
echo "=== Updating app with encrypted environment variables ==="
doctl apps update ${{ env.APP_ID }} --spec .do/app.yaml --wait
echo "Deployment completed successfully"
- name: Get deployment status
run: |
echo "=== Getting latest deployment status ==="
DEPLOYMENT_ID=$(doctl apps list-deployments ${{ env.APP_ID }} --format ID --no-header | head -1)
echo "Latest deployment ID: $DEPLOYMENT_ID"
doctl apps get-deployment ${{ env.APP_ID }} $DEPLOYMENT_ID
- name: Verify health check
run: |
echo "Waiting 30 seconds for deployment to stabilize..."
sleep 30
# Get the app URL
APP_URL=$(doctl apps get ${{ env.APP_ID }} --format DefaultIngress --no-header)
echo "App URL: $APP_URL"
# Test health endpoint
echo "=== Testing health endpoint ==="
if curl -f -s -o /dev/null -w "%{http_code}" $APP_URL/health | grep -q "200"; then
echo "✅ Health check passed!"
else
echo "❌ Health check failed"
# Get logs for debugging
echo "=== Recent deployment logs ==="
DEPLOYMENT_ID=$(doctl apps list-deployments ${{ env.APP_ID }} --format ID --no-header | head -1)
doctl apps logs ${{ env.APP_ID }} --tail=50
exit 1
fi
- name: Summary
if: success()
run: |
APP_URL=$(doctl apps get ${{ env.APP_ID }} --format DefaultIngress --no-header)
echo "## 🚀 Deployment Successful!"
echo ""
echo "- **Environment**: ${{ github.event.inputs.environment || 'production' }}"
echo "- **App URL**: $APP_URL"
echo "- **Deployed by**: ${{ github.actor }}"
echo ""
echo "### Environment Variables Status"
echo "All environment variables are encrypted and stored in app.yaml"
echo "These encrypted values are safe to commit and will persist across deployments"