Skip to content

Merge pull request #118 from go-park-mail-ru/NM-117 #35

Merge pull request #118 from go-park-mail-ru/NM-117

Merge pull request #118 from go-park-mail-ru/NM-117 #35

Workflow file for this run

name: CD
on:
push:
branches:
- main
- dev
paths:
- 'microservices/**'
- 'config/**'
- 'cmd/**'
jobs:
build:
name: Build
runs-on: ubuntu-latest
env:
ENV: prod
DOCKER_COMPOSE_PATH: docker/docker-compose.prod.yaml
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
steps:
- name: Check out code into directory
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push microservice images
run: |
services=(user playlist artist album track csat genre)
for service in "${services[@]}"; do
docker compose -f "$DOCKER_COMPOSE_PATH" build novamusic-${service}
docker tag ${DOCKER_USERNAME}/novamusic-${service}:latest ${DOCKER_USERNAME}/novamusic-${service}:${GITHUB_SHA::8}
docker push ${DOCKER_USERNAME}/novamusic-${service}:${GITHUB_SHA::8}
docker push ${DOCKER_USERNAME}/novamusic-${service}:latest
done
migrate:
name: Postgres Migration
runs-on: ubuntu-latest
needs: build
steps:
- name: Check out code into directory
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Copy migration files to server
uses: appleboy/[email protected]
with:
host: 185.241.194.24
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }}
source: "internal/db/postgres/migrations/*"
target: "/home/ubuntu/nova-music/backend/"
- name: Run database migrations
uses: appleboy/[email protected]
with:
host: 185.241.194.24
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }}
script: |
cd /home/ubuntu/nova-music/backend/
sudo make postgres-migrate