Skip to content

refactor github actions #266

refactor github actions

refactor github actions #266

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/workflows/.checkout.yml@master
- name: Build and push ${{ matrix.service }}
uses: unstructuredstudio/zubhub/.github/workflows/.docker_build_and_push.yml@master
with:
context: ./zubhub_backend/
file: ./zubhub_backend/compose/${{ matrix.service }}/prod/Dockerfile
push: true
tags: unstructuredstudio/zubhub-services_${{ matrix.service }}:latest
secrets: inherit
deploy:
needs: build_and_push
runs-on: ubuntu-latest
steps:
- uses: unstructuredstudio/zubhub/.github/workflows/.checkout.yml@master
- uses: unstructuredstudio/zubhub/.github/workflows/.scp_action.yml@master
with:
source: "."
target: "/home/zubhub-services/zubhub"
secrets: inherit
- uses: unsctructuredstudio/zubhub/.github/workflows/.ssh_action.yml@master
with:
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))
secrets: inherit