-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (65 loc) · 3.13 KB
/
deploy-sandbox.yml
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
name: Deploy to Sandbox
on:
workflow_dispatch:
push:
branches: ["develop"]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment: sandbox
steps:
- name: Checkout Develop
uses: actions/checkout@v4
- name: Build Docker Image
run: docker build -t ${{ secrets.DIGITAL_OCEAN_REGISTRY }}/ets-template-sites-cms:$(echo $GITHUB_SHA | head -c7) .
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITAL_OCEAN_TOKEN }}
- name: Login to Digital Ocean Container Registry
run: doctl registry login --expiry-seconds 1200
- name: Push Image to Container Registry
run: docker push ${{ secrets.DIGITAL_OCEAN_REGISTRY }}/ets-template-sites-cms:$(echo $GITHUB_SHA | head -c7)
- name: Set up Kubernetes Context
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ets-template-sites-cms-sandbox
- name: Deploy to Kubernetes
run: |
if kubectl get deployment ets-template-sites-cms-sandbox --ignore-not-found; then
echo "Deployment exists, updating image..."
kubectl set image deployment/ets-template-sites-cms-sandbox *=${{ secrets.DIGITAL_OCEAN_REGISTRY }}/ets-template-sites-cms:$(echo $GITHUB_SHA | head -c7)
else
echo "Creating deployment"
kubectl create deployment ets-template-sites-cms-sandbox --image=${{ secrets.DIGITAL_OCEAN_REGISTRY }}/ets-template-sites-cms:$(echo $GITHUB_SHA | head -c7)
fi
- name: Set Environment Variables
run: |
echo "${{ secrets.DB_SSL__CA_BASE64 }}" | base64 --decode > /tmp/ca-cert.crt
kubectl set env deployment/ets-template-sites-cms-sandbox --overwrite \
KEY=${{ secrets.DIRECTUS_KEY }} \
SECRET=${{ secrets.DIRECTUS_SECRET }} \
DB_CLIENT=${{ vars.DB_CLIENT }} \
DB_HOST=${{ vars.DB_HOST }} \
DB_PORT=${{ vars.DB_PORT }} \
DB_DATABASE=${{ vars.DB_DATABASE }} \
DB_USER=${{ secrets.DB_USER }} \
DB_PASSWORD=${{ secrets.DB_PASSWORD }} \
DB_SSL__CA="/tmp/ca-cert.crt" \
DB_SSL__REJECT_UNAUTHORIZED="false" \
NODE_TLS_REJECT_UNAUTHORIZED="0" \
STORAGE_LOCATIONS="gcs" \
STORAGE_GCS_DRIVER="gcs" \
STORAGE_GCS_BUCKET="ets-template-sites-sandbox" \
CORS_ENABLED=${{ vars.CORS_ENABLED }} \
CORS_ORIGIN=${{ vars.CORS_ORIGIN }} \
ADMIN_EMAIL=${{ secrets.ADMIN_EMAIL }} \
ADMIN_PASSWORD=${{ secrets.ADMIN_PASSWORD }} \
- name: Create Load Balancer Service
run: |
if kubectl get service ets-template-sites-cms-sandbox-load-balancer --ignore-not-found; then
echo "Load balancer service already exists"
else
kubectl expose deployment ets-template-sites-cms-sandbox --type=LoadBalancer --name=ets-template-sites-cms-sandbox-load-balancer --port=80 --target-port=8055
echo "Creating Load Balancer Service..."
fi
- name: Verify Deployment
run: kubectl rollout status deployment/ets-template-sites-cms-sandbox