This repository has been archived by the owner on Apr 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add github actions to build and deploy
- Loading branch information
1 parent
684f611
commit faf5790
Showing
3 changed files
with
62 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|