-
Notifications
You must be signed in to change notification settings - Fork 2
117 lines (106 loc) · 5.48 KB
/
deployer.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
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
on:
workflow_dispatch:
branch:
description: 'branch'
default: 'master'
required: true
jobs:
build-and-publish:
name: Build and Publish images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.2
name: Check out code
with:
ref: '${{ github.event.inputs.branch}}'
- uses: mr-smithers-excellent/docker-build-push@v5
name: Build and Publish Frontend
with:
image: koto/frontend
tags: ${{ github.run_number }}, latest
registry: ghcr.io
githubOrg: kotollc
username: ${{ github.actor }}
password: ${{ secrets.GH_TOKEN }}
directory: ./frontend
dockerfile: ./frontend/Dockerfile.production
- uses: mr-smithers-excellent/docker-build-push@v5
name: Build and Publish Userhub
with:
image: koto/userhub
tags: ${{ github.run_number }}, latest
registry: ghcr.io
githubOrg: kotollc
username: ${{ github.actor }}
password: ${{ secrets.GH_TOKEN }}
directory: ./backend
dockerfile: ./backend/userhub/Dockerfile
- uses: mr-smithers-excellent/docker-build-push@v5
name: Build and Publish Messagehub
with:
image: koto/messagehub
tags: ${{ github.run_number }}, latest
registry: ghcr.io
githubOrg: kotollc
username: ${{ github.actor }}
password: ${{ secrets.GH_TOKEN }}
directory: ./backend
dockerfile: ./backend/messagehub/Dockerfile
deploy-to-staging:
runs-on: ubuntu-latest
needs: build-and-publish
env:
DO_CLUSTER_ID: "4626b044-a746-4205-9ab7-16c863182602"
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: '${{ github.event.inputs.branch}}'
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Save DigitalOcean kubeconfig
run: doctl kubernetes cluster kubeconfig save ${{ env.DO_CLUSTER_ID }}
- name: Update deployment file (staging)
run: |
sed -i 's|<TAG>|'${{ github.run_number }}'|' $GITHUB_WORKSPACE/.k8s/production/backend/user-hub.yaml
sed -i 's|<TAG>|'${{ github.run_number }}'|' $GITHUB_WORKSPACE/.k8s/production/frontend/frontend.yaml
sed -i 's|<TAG>|'${{ github.run_number }}'|' $GITHUB_WORKSPACE/.k8s/production/backend/message-hub.yaml
- name: (re) deploy the cert-manager and ingress controller
run: |
helm repo add jetstack https://charts.jetstack.io
helm repo update
helm upgrade --install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace --version v1.3.0 --set installCRDs=true
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm upgrade --install nginx-ingress ingress-nginx/ingress-nginx --set controller.publishService.enabled=true
- name: (re) create secrets
run: |
kubectl delete secret db-message-hub-password --ignore-not-found -n backend
kubectl delete secret db-user-hub-password --ignore-not-found -n backend
kubectl delete secret message-hub-secrets --ignore-not-found -n backend
kubectl delete secret user-hub-s3 --ignore-not-found -n backend
kubectl delete secret user-hub-smtp --ignore-not-found -n backend
kubectl delete secret pgadmin --ignore-not-found -n backend
kubectl delete secret user-hub-firebase --ignore-not-found -n backend
kubectl delete secret user-hub-key --ignore-not-found -n backend
kubectl delete secret do-token --ignore-not-found -n backend
kubectl create secret generic db-message-hub-password --from-literal=password="${{ secrets.K8S_COMMON_SECRET }}" -n backend
kubectl create secret generic db-user-hub-password --from-literal=password="${{ secrets.K8S_COMMON_SECRET }}" -n backend
kubectl create secret generic message-hub-secrets --from-literal=s3_key="${{ secrets.DIGITALOCEAN_S3_KEY }}" --from-literal=s3_secret="${{ secrets.DIGITALOCEAN_S3_SECRET }}" -n backend
kubectl create secret generic user-hub-s3 --from-literal=s3_key="${{ secrets.DIGITALOCEAN_S3_KEY }}" --from-literal=s3_secret="${{ secrets.DIGITALOCEAN_S3_SECRET }}" -n backend
kubectl create secret generic user-hub-smtp --from-literal=smtp_user="postmaster@mg.peacenik.app" --from-literal=smtp_password="${{ secrets.MAILGUN_PASSWORD }}" -n backend
kubectl create secret generic pgadmin --from-literal=pgadmin-password="${{ secrets.PGADMIN_PASSWORD }}" -n backend
kubectl create secret generic user-hub-firebase --from-literal=firebase_token="${{ secrets.FIREBASE_TOKEN }}" -n backend
kubectl create secret generic user-hub-key --from-literal=password="${{ secrets.USERHUB_SECRET }}" -n backend
kubectl create secret generic do-token --from-literal=token="${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}" -n backend
- name: Deploy Frontend and User-hub to DigitalOcean Kubernetes (production)
run: |
kubectl apply --recursive -f $GITHUB_WORKSPACE/.k8s/production/ --force
- name: Slack notify
uses: edge/simple-slack-notify@master
with:
channel: '#engineering'
text: 'Branch ${{ github.event.inputs.branch }} pushed'
color: 'good'