56 lines
1.8 KiB
YAML
56 lines
1.8 KiB
YAML
name: Docker Deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
|
|
jobs:
|
|
build_and_deploy:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
|
|
|
|
|
- name: Build and push Docker frontend image
|
|
uses: docker/build-push-action@v3
|
|
with:
|
|
context: ./frontend
|
|
file: ./frontend/Dockerfile
|
|
push: true
|
|
tags: azpect3120/file.gophernest.frontend:latest
|
|
|
|
- name: Build and push Docker backend image
|
|
uses: docker/build-push-action@v3
|
|
with:
|
|
context: ./backend
|
|
file: ./backend/Dockerfile
|
|
push: true
|
|
tags: azpect3120/file.gophernest.backend:latest
|
|
|
|
- name: Deploy to server
|
|
uses: appleboy/ssh-action@v1.2.1
|
|
with:
|
|
host: ${{ secrets.SERVER_HOST }}
|
|
username: ${{ secrets.SERVER_USER }}
|
|
password: ${{ secrets.SERVER_PASSWORD }}
|
|
port: 22
|
|
script: |
|
|
docker-compose -f /home/azpect/Applications/file.gophernest/docker-compose.yml down
|
|
docker-compose -f /home/azpect/Applications/file.gophernest/docker-compose.yml pull
|
|
docker-compose -f /home/azpect/Applications/file.gophernest/docker-compose.yml up -d
|
|
env:
|
|
FILE_GOPHERNEST_USER: ${{ secrets.FILE_GOPHERNEST_USER }}
|
|
FILE_GOPHERNEST_PASSWORD: ${{ secrets.FILE_GOPHERNEST_PASSWORD }}
|
|
FILE_GOPHERNEST_JWT_SECRET: ${{ secrets.FILE_GOPHERNEST_JWT_SECRET }}
|
|
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} |