-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (103 loc) · 4.11 KB
/
Copy pathdeploy.yml
File metadata and controls
120 lines (103 loc) · 4.11 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Build and Deploy Flash API Docs
on:
push:
branches:
- main
workflow_dispatch:
inputs:
environment:
description: 'Environment to deploy to'
required: true
default: 'production'
type: choice
options:
- production
- staging
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Fetch schema and build documentation
run: npm run build
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: site-build
path: public/
if-no-files-found: error
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: site-build
path: public
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Verify DigitalOcean Permissions
run: |
echo "Checking DigitalOcean access..."
doctl account get || {
echo "::error::Failed to access DigitalOcean account. Please check your DIGITALOCEAN_ACCESS_TOKEN secret."
echo "The token needs to have both read and write access to apps."
echo "You can create a new token at https://cloud.digitalocean.com/account/api/tokens"
exit 1
}
echo "Checking App Platform access..."
# Just list apps to verify app platform access
doctl apps list || {
echo "::error::Failed to access DigitalOcean App Platform. Please check your token has the apps scope."
exit 1
}
- name: Deploy to DigitalOcean App Platform
run: |
# Create tar of the public directory
tar -czf deploy.tar.gz -C public .
# Verify that the APP_ID is set
if [ -z "${{ secrets.DIGITALOCEAN_APP_ID }}" ]; then
echo "::error::DIGITALOCEAN_APP_ID is not set. Please add this secret in your repository settings."
exit 1
fi
# Check App ID format (UUID validation)
APP_ID="${{ secrets.DIGITALOCEAN_APP_ID }}"
if ! [[ $APP_ID =~ ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$ ]]; then
echo "::error::Invalid App ID format. The App ID should be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
echo "Please check DIGITALOCEAN_SETUP.md for instructions on finding your correct App ID."
exit 1
fi
# List available apps to help debugging
echo "Available DigitalOcean apps:"
doctl apps list --format ID,Spec.Name,DefaultIngress --no-header
# Deploy to DigitalOcean App Platform
echo "Deploying to DigitalOcean App Platform (App ID: $APP_ID)..."
# Try the deployment with more verbose output
doctl apps create-deployment "$APP_ID" --wait --format ID --verbose || {
echo "::error::Failed to deploy to DigitalOcean App Platform."
echo "Error: invalid uuid suggests the App ID is not correctly formatted."
echo ""
echo "To find your correct App ID:"
echo "1. Go to https://cloud.digitalocean.com/apps"
echo "2. Click on your app"
echo "3. The App ID is in the URL: https://cloud.digitalocean.com/apps/YOUR-APP-ID-HERE"
echo "4. It should look like: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
echo ""
echo "Update your DIGITALOCEAN_APP_ID secret with this value."
exit 1
}
- name: Deployment Summary
run: |
echo "✅ Flash API Documentation has been successfully deployed to DigitalOcean!"
echo "🔗 Live URL: https://flash-api-docs.${GITHUB_REF_NAME/main/flashapp.me}"