-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (51 loc) · 1.94 KB
/
Copy pathdeploy.yml
File metadata and controls
59 lines (51 loc) · 1.94 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
name: Deploy
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
environment: Production
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Docker login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push — client
uses: docker/build-push-action@v5
with:
context: ./client
file: ./client/Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/cca-client:${{ github.sha }}
- name: Build and push — server
uses: docker/build-push-action@v5
with:
context: ./server
file: ./server/Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/cca-server:${{ github.sha }}
- name: Build and push — ai-service
uses: docker/build-push-action@v5
with:
context: ./ai-service
file: ./ai-service/Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/cca-ai-service:${{ github.sha }}
- name: Deploy to VM
run: |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/ssh_key
chmod 600 ~/ssh_key
ssh -o StrictHostKeyChecking=no -i ~/ssh_key ${{ secrets.VM_USER }}@${{ secrets.VM_HOST }} -t "
cd ~/codebase-chat-assistant &&
MONGODB_URI='${{ secrets.MONGODB_URI }}' \
JWT_SECRET='${{ secrets.JWT_SECRET }}' \
GOOGLE_API_KEY='${{ secrets.GOOGLE_API_KEY }}' \
CLIENT_IMAGE='${{ secrets.DOCKERHUB_USERNAME }}/cca-client:${{ github.sha }}' \
SERVER_IMAGE='${{ secrets.DOCKERHUB_USERNAME }}/cca-server:${{ github.sha }}' \
AI_SERVICE_IMAGE='${{ secrets.DOCKERHUB_USERNAME }}/cca-ai-service:${{ github.sha }}' \
docker compose up -d --pull always --remove-orphans
"