Build, Test, and Push Services #30
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-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
# 1. Checkout репозиторий | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Build and push ads_service | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./microservices/ads_service/Dockerfile | |
tags: ads_service:latest | |
- name: Build and push auth_service | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./microservices/auth_service/Dockerfile | |
tags: auth_service:latest | |
- name: Build and push city_service | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./microservices/city_service/Dockerfile | |
tags: city_service:latest | |
- name: Build and push migrator | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./cmd/migrator/Dockerfile | |
tags: migrator:latest | |
- name: Build and push backend | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./Dockerfile | |
tags: backend:latest | |
- name: Save Docker Images | |
run: | | |
docker save ads_service city_service migrator backend auth_service > images.tar | |
# 4. Передача образа на виртуалку | |
- name: Transfer Docker Image to Virtual Machine | |
uses: appleboy/scp-action@v0.1.7 | |
with: | |
host: 37.139.41.110 | |
username: ubuntu | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
source: ./images.tar | |
target: /tmp/images.tar | |
# Передача docker-compose.yml | |
- name: Transfer Docker Compose to Virtual Machine | |
uses: appleboy/scp-action@v0.1.7 | |
with: | |
host: 37.139.41.110 | |
username: ubuntu | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
source: ./docker-compose.yml | |
target: /tmp/docker-compose.yml | |
# 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: | | |
docker load -i /tmp/images.tar | |
docker compose -f /tmp/docker-compose.yml up -d |