-
Notifications
You must be signed in to change notification settings - Fork 142
107 lines (94 loc) · 3 KB
/
test-build-deploy.yml
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
99
100
101
102
103
104
105
106
107
name: Build Docker Images
on:
push:
branches:
- main
jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: npm ci && npx playwright install --with-deps
- name: Start the development server
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
NEXT_PUBLIC_APP_URL: http://localhost:8080
NEXT_PUBLIC_API_URL: http://localhost:3333
LUNARY_PUBLIC_KEY: 259d2d94-9446-478a-ae04-484de705b522
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: npm run dev:test & npx wait-on http://localhost:3333/v1/health
- name: Run tests
run: npx playwright test
env:
BASE_URL: http://localhost:8080
DATABASE_URL: ${{ secrets.DATABASE_URL }}
build-and-push:
needs: run-tests
runs-on: ubuntu-latest
steps:
- name: Check out the private Ops repo
uses: actions/checkout@v4
with:
token: ${{ secrets.ACCESS_TOKEN }}
submodules: "recursive"
- name: Generate timestamp
id: timestamp
run: echo "::set-output name=timestamp::$(date +%Y%m%d%H%M%S)"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to private Docker Registry
uses: docker/login-action@v3
with:
registry: registry.lunary.ai
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
- name: Build and push backend
uses: docker/build-push-action@v5
with:
context: .
file: ./ops/backend/Dockerfile
push: true
tags: registry.lunary.ai/backend:latest
platforms: linux/amd64
- name: Build and push radar
uses: docker/build-push-action@v5
with:
context: .
file: ./ops/radar/Dockerfile
push: true
tags: registry.lunary.ai/radar:latest
platforms: linux/amd64
- name: Build and push frontend
uses: docker/build-push-action@v5
with:
context: .
file: ./ops/frontend/Dockerfile
push: true
tags: registry.lunary.ai/frontend:latest
platforms: linux/amd64
- name: Build and push db
uses: docker/build-push-action@v5
with:
context: .
file: ./ops/db/Dockerfile
push: true
tags: registry.lunary.ai/db:latest
platforms: linux/amd64
deploy:
needs: build-and-push
runs-on: ubuntu-latest
steps:
- name: Deploy to Production
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.PRODUCTION_IP_ADDRESS }}
username: root
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 3855
script: |
cd /opt/lunary
docker compose pull
docker compose down
docker compose up -d