Skip to content

Workflow file for this run

name: Build and Deploy Docker image
on:
push:
branches: [ "master" ]
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Clear Docker context
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
script: |
docker compose down --remove-orphans -v
docker system prune -a -f
- name: Send files to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
source: ./vocab_dictionnary/
target: api
- name: Build API Image
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
script: |
cd /${{ secrets.SERVER_USERNAME }}/api/vocab_dictionnary/
docker build -t vocab_dictionnary:1.0 .
docker network create api-network-prod
- name: Mount Containers
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
script: |
docker compose -f ./api/vocab_dictionnary/docker-compose.yml up -d
- name: Run Database Migrations
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
script: |
cd /${{ secrets.SERVER_USERNAME }}/api/vocab_dictionnary/
docker compose exec web python manage.py makemigrations
docker compose exec web python manage.py migrate