Skip to content

Commit

Permalink
ci: add deploy workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Adibov committed Nov 23, 2023
1 parent 3b67abf commit 67b0b20
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 3 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Deploy

on:
push:
branches:
- master
- add-deploy-workflow # FIXME: remove this line
workflow_dispatch: # This will make the workflow dispatched only manually

jobs:
build-and-push:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Compose
uses: ndeloof/[email protected]
with:
version: v2.20.2

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build docker images
run: docker compose build

- name: Push docker images
run: docker compose push backend

deploy:
needs: build-and-push
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install Compose
uses: ndeloof/[email protected]
with:
version: v2.20.2

- name: Deploy to the VM
uses: appleboy/ssh-action@master
with:
host: ${{ vars.VM_HOST }}
username: ${{ vars.VM_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
docker compose pull
docker compose up -d
2 changes: 1 addition & 1 deletion backend/aaiss_backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,4 @@
PAYWALL = env.str("PAYWALL", "ZIFY")

#ZIFY
ZIFY_AUTH = env.str("ZIFY_AUTH")
ZIFY_AUTH = env.str("ZIFY_AUTH", "")
6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ version: '3.8'

services:
migrate_db:
image: aaissaut/aaiss:backend
build: ./backend
command: ./manage.py migrate
volumes:
- ./backend/data:/backend-aaiss/data

web:
backend:
depends_on:
migrate_db:
condition: service_completed_successfully
image: aaissaut/aaiss:backend
build: ./backend
command: gunicorn aaiss_backend.wsgi:application --bind 0.0.0.0:6446
volumes:
Expand All @@ -26,7 +28,7 @@ services:

caddy:
depends_on:
web:
backend:
condition: service_healthy
image: caddy:2.7.3
volumes:
Expand Down

0 comments on commit 67b0b20

Please sign in to comment.