-
Notifications
You must be signed in to change notification settings - Fork 7
82 lines (70 loc) · 2.31 KB
/
server-ci-cd.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
name: Server CI/CD
on:
push:
branches: [develop]
paths:
- 'server/**'
- 'core/**'
- '.github/workflows/server-ci-cd.yml'
- 'Dockerfile.server'
- 'docker-compose.yml'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: '9'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Create .env file
working-directory: ./server
run: |
echo "REDIS_HOST=${{ secrets.REDIS_HOST }}" >> .env
echo "REDIS_PORT=${{ secrets.REDIS_PORT }}" >> .env
echo "CLOVA_API_KEY=${{ secrets.CLOVA_API_KEY }}" >> .env
echo "CLOVA_GATEWAY_KEY=${{ secrets.CLOVA_GATEWAY_KEY }}" >> .env
- name: Run tests
run: pnpm --filter server test | true
docker-deploy:
needs: ci
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Docker Setup
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.server
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/troublepainter-server:latest
build-args: |
REDIS_HOST=${{ secrets.REDIS_HOST }}
REDIS_PORT=${{ secrets.REDIS_PORT }}
CLOVA_API_KEY=${{ secrets.CLOVA_API_KEY }}
CLOVA_GATEWAY_KEY=${{ secrets.CLOVA_GATEWAY_KEY }}
- name: Deploy to Server
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: mira
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd /home/mira/web30-stop-troublepainter
export DOCKERHUB_USERNAME=${{ secrets.DOCKERHUB_USERNAME }}
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/troublepainter-server:latest
docker compose up -d server