-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (65 loc) · 2.06 KB
/
cd.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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