-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (83 loc) · 2.66 KB
/
deploy.yml
File metadata and controls
98 lines (83 loc) · 2.66 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: Deploy Jobvyn
on:
push:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install auth dependencies
run: cd backend/auth && npm ci
- name: Run auth tests
run: cd backend/auth && npm test
env:
JWT_SECRET: ${{ secrets.JWT_SECRET }}
FRONTEND_URL: http://localhost:3000
UPLOAD_SERVICE_URL: http://localhost:5004
build-and-deploy:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build & push frontend
uses: docker/build-push-action@v5
with:
context: ./frontend
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/frontend:latest
- name: Build & push auth
uses: docker/build-push-action@v5
with:
context: ./backend/auth
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/auth:latest
- name: Build & push user
uses: docker/build-push-action@v5
with:
context: ./backend/user
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/user:latest
- name: Build & push utils
uses: docker/build-push-action@v5
with:
context: ./backend/utils
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/utils:latest
- name: Build & push job
uses: docker/build-push-action@v5
with:
context: ./backend/job
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/job:latest
- name: Build & push payment
uses: docker/build-push-action@v5
with:
context: ./backend/payment
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/payment:latest
- name: Build & push gateway
uses: docker/build-push-action@v5
with:
context: ./backend/gateway
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/gateway:latest
- name: Deploy to EC2
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_SSH_KEY }}
script: |
cd /home/ubuntu/deploy
docker compose -f docker-compose.lite.yml pull
docker compose -f docker-compose.lite.yml up -d --force-recreate
docker image prune -f