Skip to content

Policy deploy.yml

Policy deploy.yml #29

Workflow file for this run

name: Deploy services
on:
push:
branches: [ 'main' ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
frontend:
- 'frontend/**'
backend:
- 'backend/**'
- name: "Set up QEMU"
uses: docker/setup-qemu-action@v1
- name: "Set up Docker Buildx"
uses: docker/setup-buildx-action@v1
- name: "Login to Docker Hub"
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: "Build and push | backend"
if: steps.changes.outputs.backend == 'true'
uses: docker/build-push-action@v4
with:
context: backend/
file: backend/Dockerfile
tags: ${{ secrets.DOCKERHUB_USERNAME }}/ai-backend:latest
push: true
- name: "Build and push | frontend"
if: steps.changes.outputs.frontend == 'true'
uses: docker/build-push-action@v4
with:
context: frontend/
file: frontend/Dockerfile
tags: ${{ secrets.DOCKERHUB_USERNAME }}/ai-frontend:latest
push: true
- name: "Run deploy on server"
uses: appleboy/ssh-action@v0.1.4
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
script: |
cd dune-ai
sudo docker compose -f docker-compose.yaml -p dune-ai pull
sudo docker compose -f docker-compose.yaml -p dune-ai up -d