-
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.
- Loading branch information
1 parent
8be179a
commit 79a969a
Showing
1 changed file
with
14 additions
and
16 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 |
---|---|---|
|
@@ -5,29 +5,27 @@ on: | |
branches: ["deploy"] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Docker | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Build Docker image | ||
run: docker-compose build --progress=plain --no-cache -t fight-club-backend:latest . | ||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Install rsync | ||
run: sudo apt-get update && sudo apt-get install -y rsync | ||
- name: Copy code to server using rsync | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: 37.139.41.110 | ||
username: ubuntu | ||
key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
script: | | ||
rsync -avz -e "ssh -p 22" ./ [email protected]:/opt/backend-deploy/ | ||
- name: Build and deploy on server | ||
- name: Save Docker image | ||
run: docker save fight-club-backend:latest > fight-club-backend.tar | ||
- name: Transfer image to server via SSH | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: 37.139.41.110 | ||
username: ubuntu | ||
key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
script: | | ||
sudo apt update && sudo apt install -y docker.io docker-compose | ||
cd /opt/backend-deploy/ | ||
sudo docker-compose build --no-cache | ||
sudo mkdir -p /opt/docker-images | ||
cat fight-club-backend.tar | sudo docker load -i - | ||
sudo docker-compose up -d --remove-orphans |