Skip to content

fix: Api deploy

fix: Api deploy #23

Workflow file for this run

name: Deploy API TO VPS
on:
push:
branches:
- dev # Set this to your default branch
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and Push Docker image
uses: docker/build-push-action@v2
with:
context: ./API
file: ./API/Dockerfile
push: true
tags: dfanso/quick-quest_backend:latest
build-args: |
MONGO_URI=${{ secrets.MONGO_URI }}
AWS_REGION=${{ secrets.AWS_REGION }}
AWS_BUCKET_NAME=${{ secrets.AWS_BUCKET_NAME }}
AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}
COGNITO_USER_POOL_ID=${{ secrets.COGNITO_USER_POOL_ID }}
COGNITO_CLIENT_ID=${{ secrets.COGNITO_CLIENT_ID }}
COGNITO_CLIENT_SECRET=${{ secrets.COGNITO_CLIENT_SECRET }}
- name: SSH and Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USERNAME }}
password: ${{ secrets.VPS_PASSWORD }}
script: |
docker pull dfanso/quick-quest_backend:latest
docker stop quick-quest_backend || true
docker rm quick-quest_backend || true
docker run -d --name quick-quest_backend -p 9000:9000 dfanso/quick-quest_backend:latest