-
Notifications
You must be signed in to change notification settings - Fork 9
52 lines (45 loc) · 1.63 KB
/
cd-stage.yaml
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
name: Deploy to Staging
concurrency: stage
on:
push:
branches: [master, gql]
jobs:
build-push:
name: Build and Push Images
uses: ./.github/workflows/cd.yaml
with:
tag: latest
secrets: inherit
deploy:
name: Deploy with SSH
needs: [build-push]
runs-on: ubuntu-latest
environment: staging
steps:
- name: SSH and Helm Install
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: root
key: ${{ secrets.SSH_KEY }}
script: |
set -e # Exit immediately if a command fails
cd ./infra
# Check if the Helm release exists
if helm status bt-stage-app ; then
# Restart deployments if the Helm release exists
kubectl rollout restart deployment bt-stage-app-backend
kubectl rollout restart deployment bt-stage-app-frontend
else
# Install the Helm release if it doesn't exist
helm install bt-stage-app ./app --namespace=bt \
--set env=stage \
--set frontend.image.tag=latest \
--set backend.image.tag=latest \
--set host=staging.stanfurdtime.com \
--set mongoUri=mongodb://bt-stage-mongo-mongodb.bt.svc.cluster.local:27017/bt \
--set redisUri=redis://bt-stage-redis-master.bt.svc.cluster.local:6379
fi
# Check container status
kubectl rollout status --timeout=180s deployment bt-stage-app-backend
kubectl rollout status --timeout=180s deployment bt-stage-app-frontend