Build, Test, and Push Services #38
Workflow file for this run
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
name: Build and Deploy | ||
on: | ||
push: | ||
branches: | ||
- deploy | ||
jobs: | ||
# build: | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# # 1. Checkout репозиторий | ||
# - name: Checkout code | ||
# uses: actions/checkout@v4 | ||
# # 2. Логинимся в DockerHub | ||
# - name: Login to DockerHub Registry | ||
# run: echo dckr_pat_6HmV5MDVrUU3Wfzu59ejhGGOBjs | docker login -u rasulovarsen --password-stdin | ||
# # 3. Build ads_service | ||
# - name: Build and push ads_service | ||
# uses: docker/build-push-action@v4 | ||
# with: | ||
# context: . | ||
# file: ./microservices/ads_service/Dockerfile | ||
# tags: rasulovarsen/ads_service:latest | ||
# push: true | ||
# - name: Build and push auth_service | ||
# uses: docker/build-push-action@v4 | ||
# with: | ||
# context: . | ||
# file: ./microservices/auth_service/Dockerfile | ||
# tags: rasulovarsen/auth_service:latest | ||
# push: true | ||
# - name: Build and push city_service | ||
# uses: docker/build-push-action@v4 | ||
# with: | ||
# context: . | ||
# file: ./microservices/city_service/Dockerfile | ||
# tags: rasulovarsen/city_service:latest | ||
# push: true | ||
# - name: Build and push migrator | ||
# uses: docker/build-push-action@v4 | ||
# with: | ||
# context: . | ||
# file: ./cmd/migrator/Dockerfile | ||
# tags: rasulovarsen/migrator:latest | ||
# push: true | ||
# - name: Build and push backend | ||
# uses: docker/build-push-action@v4 | ||
# with: | ||
# context: . | ||
# file: ./Dockerfile | ||
# tags: rasulovarsen/backend:latest | ||
# push: true | ||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
# 5. Развертывание на виртуалке | ||
- name: Deploy on Virtual Machine | ||
uses: appleboy/ssh-action@v1.2.0 | ||
with: | ||
host: 37.139.41.110 | ||
username: ubuntu | ||
key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
script: | | ||
cd /home/ubuntu/ | ||
if [ ! -d backend ]; then git clone https://github.com/go-park-mail-ru/2024_2_Fight-club backend | ||
else cd backend | ||
fi | ||
git fetch --all | ||
git switch deploy -f | ||
git reset --hard origin/deploy | ||
docker rm -f $(sudo docker ps -aq) | ||
docker compose up -d |