Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Commit

Permalink
add github actions to build and deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
quillcraftsman committed Sep 17, 2023
1 parent 684f611 commit faf5790
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 4 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/build-and-publish-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# .github/workflows/build-and-publish-images.yml
name: Build and push to DockerHub

on:
push:
branches: ["main"]

jobs:
build_and_push_to_docker_hub:
name: Build and push to DockerHub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up Docker Build
uses: docker/setup-buildx-action@v2
- name: Login to Docker
uses: docker/login-action@v2
with:
username: findsimilar
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push to DockerHub
run: |
docker compose build
docker compose push
37 changes: 37 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# .github/workflows/deploy.yml
name: Deploy to production server

on:
workflow_run:
workflows: ["Build and push to DockerHub"]
branches: ["main"]
types:
- completed

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Copy docker-compose.production.yml via ssh
uses: appleboy/scp-action@master
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USERNAME }}
password: ${{ secrets.DEPLOY_PASSWORD }}
port: ${{ secrets.DEPLOY_PORT }}
source: "docker-compose.production.yml"
target: "demo-gateway"
- name: Executing remote ssh commands to deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USERNAME }}
password: ${{ secrets.DEPLOY_PASSWORD }}
port: ${{ secrets.DEPLOY_PORT }}
script: |
cd demo-gateway
docker compose -f docker-compose.production.yml pull
docker compose -f docker-compose.production.yml down
docker compose -f docker-compose.production.yml up -d
4 changes: 0 additions & 4 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
upstream backend {
server 0.0.0.0:8000;
}

server {
listen 80;
server_name api.findsimilar.org;
Expand Down

0 comments on commit faf5790

Please sign in to comment.