Skip to content

Build, Test, and Push Services #33

Build, Test, and Push Services

Build, Test, and Push Services #33

Workflow file for this run

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: 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: 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: city_service:latest
push: true
- name: Build and push migrator
uses: docker/build-push-action@v4
with:
context: .
file: ./cmd/migrator/Dockerfile
tags: migrator:latest
push: true
- name: Build and push backend
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
tags: backend:latest
push: true
deploy:
runs-on: ubuntu-latest
needs: build
steps:
# Передача docker-compose.yml
- name: Transfer Docker Compose to Virtual Machine
uses: appleboy/[email protected]
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/[email protected]
with:
host: 37.139.41.110
username: ubuntu
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
docker compose -f /tmp/docker-compose.yml/docker-compose.yml up -d