-
Notifications
You must be signed in to change notification settings - Fork 3
74 lines (67 loc) · 2.35 KB
/
ci.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
name: 🚀 Deploy
on:
push:
branches:
- main
- dev
pull_request: {}
permissions:
actions: write
contents: read
jobs:
build:
name: 🐳 build
uses: ./.github/workflows/build.yml
secrets: inherit
deploy:
name: 🚀 Deploy
runs-on: [self-hosted]
needs: [build]
# needs: [build]
# only build/deploy main branch on pushes
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') && github.event_name == 'push' }}
env:
JWT_SECRET: ${{ secrets.JWT_SECRET }}
PORT: ${{ secrets.PORT }}
RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }}
FRONTEND_URL: ${{ secrets.FRONTEND_URL }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET: ${{ secrets.AWS_SECRET }}
AWS_BUCKET_NAME: ${{ secrets.AWS_BUCKET_NAME }}
AWS_REGION: ${{ secrets.AWS_REGION }}
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
STRIPE_WEBHOOK_SECRET: ${{ secrets.STRIPE_WEBHOOK_SECRET }}
steps:
- name: Cache node modules
uses: actions/[email protected]
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: ⬇️ Checkout repo
uses: actions/[email protected]
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: 🚀 Run Docker Compose on Staging
# if: ${{ github.ref == 'refs/heads/dev' }}
# env:
# DATABASE_URL: ${{ secrets.DATABASE_URL_STAGING }}
# FRONTEND_URL: ${{ secrets.FRONTEND_URL_STAGING }}
# run: |
# docker pull algomax/nestjs-chat-api:latest
# docker compose -f docker-compose.dev.yaml up -d
# docker system prune --all --volumes --force
- name: 🚀 Run Docker Compose on Production
if: ${{ github.ref == 'refs/heads/main' }}
# env:
# FRONTEND_URL: ${{ secrets.FRONTEND_URL }}
# DATABASE_URL: ${{ secrets.DATABASE_URL }}
run: |
docker pull algomax/nestjs-chat-api:production
docker compose -f docker-compose.prod.yaml up -d
docker system prune --all --volumes --force