-
Notifications
You must be signed in to change notification settings - Fork 168
60 lines (53 loc) · 2.1 KB
/
build_deploy_backend.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
name: Backend Production Deployment
on:
push:
branches:
- master
paths:
- "zubhub_backend/**"
- "!zubhub_backend/zubhub/docs/**"
- "!zubhub_backend/.gitignore"
- "!zubhub_backend/.env.example"
- "!zubhub_backend/.dockerignore"
workflow_dispatch:
jobs:
build_and_push:
runs-on: ubuntu-latest
strategy:
matrix:
service: ['web', 'celery', 'media']
steps:
- uses: unstructuredstudio/zubhub/.github/actions/checkout@master
- name: Build and push ${{ matrix.service }}
uses: unstructuredstudio/zubhub/.github/actions/docker_build_and_push@master
with:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
context: ./zubhub_backend/
file: ./zubhub_backend/compose/${{ matrix.service }}/prod/Dockerfile
push: true
tags: unstructuredstudio/zubhub-services_${{ matrix.service }}:latest
deploy:
needs: build_and_push
runs-on: ubuntu-latest
steps:
- uses: unstructuredstudio/zubhub/.github/actions/checkout@master
- uses: unstructuredstudio/zubhub/.github/actions/scp_action@master
with:
host: ${{ secrets.DO_BACKEND_HOST }}
username: ${{ secrets.DO_BACKEND_USERNAME }}
key: ${{ secrets.DO_SSHKEY }}
source: "."
target: "/home/zubhub-services/zubhub"
- uses: unsctructuredstudio/zubhub/.github/actions/ssh_action@master
with:
host: ${{ secrets.DO_BACKEND_HOST }}
username: ${{ secrets.DO_BACKEND_USERNAME }}
key: ${{ secrets.DO_SSHKEY }}
script: |
cp /home/zubhub-services/zubhub/zubhub_backend/compose/deploy_backend.sh /home/zubhub-services/
sudo bash /home/zubhub-services/deploy_backend.sh
doctl compute droplet list 'zubhub-services*' > droplets.txt
droplets_count=`wc -l < droplets.txt`
rm droplets.txt
docker service scale zubhub-services_web=$(($droplets_count - 1))