Skip to content

Merge pull request #42 from zubedev/feat/upgrade-packages #17

Merge pull request #42 from zubedev/feat/upgrade-packages

Merge pull request #42 from zubedev/feat/upgrade-packages #17

Workflow file for this run

name: CD
on:
push:
branches: ["master", "main"]
concurrency:
group: cd-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PYTHON_VERSION: 3.11
POETRY_VERSION: 1.6.1
jobs:
tests:
uses: ./.github/workflows/ci.yml
build:
name: "Deputy Build"
runs-on: ubuntu-latest
needs: tests
steps:
- uses: actions/checkout@v4
- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: docker/setup-buildx-action@v2
- uses: docker/build-push-action@v4
with:
context: .
file: ./docker/prod/Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/deputy:${{ github.sha }}
${{ secrets.DOCKERHUB_USERNAME }}/deputy:latest
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
name: "Deputy Deploy"
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- uses: appleboy/ssh-action@v1.0.0 # deploy app using ssh
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
script: |
docker stop deputy beat || true
docker rm deputy beat || true
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/deputy:latest
./run_deputy
./run_beat
- uses: appleboy/ssh-action@v1.0.0 # deploy worker using ssh
with:
host: ${{ secrets.WB_HOST }}
username: ${{ secrets.WB_USERNAME }}
key: ${{ secrets.WB_KEY }}
script: |
export PATH="/usr/local/bin:$PATH"
cd apps/deputy
docker stop worker || true
docker rm worker || true
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/deputy:latest
./run_worker
- uses: superfly/flyctl-actions/setup-flyctl@master # setup flyctl
- run: |
./scripts/fly_machines_destroy
sleep 10 # wait for machines to be destroyed
flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}