-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (55 loc) · 1.75 KB
/
api.node.js.yml
File metadata and controls
66 lines (55 loc) · 1.75 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
name: Node.js CI/CD API server
on:
push:
branches: ["main"]
paths:
- .github/workflows/api.node.js.yml
- server/**
pull_request:
branches: ["main"]
paths:
- .github/workflows/api.node.js.yml
- server/**
workflow_dispatch:
jobs:
build:
runs-on: self-hosted
strategy:
matrix:
node-version: [20.x]
defaults:
run:
working-directory: server
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
sparse-checkout: "server"
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
cache-dependency-path: "server/package-lock.json"
- name: Install dependencies
run: npm ci --legacy-peer-deps
- name: Create .env file
run: |
cat <<EOF > .env.production
NODE_ENV=production
SERVER_PORT=${{ vars.SERVER_PORT }}
API_BASE_PATH=${{ vars.API_BASE_PATH }}
CLIENT_BASE_URL=${{ vars.CLIENT_BASE_URL }}
JWT_SECRET=${{ secrets.JWT_SECRET }}
DATABASE_URL=${{ secrets.DATABASE_URL }}
STRIPE_PK=${{ secrets.STRIPE_PK }}
STRIPE_SK=${{ secrets.STRIPE_SK }}
CLOUDINARY_NAME=${{ secrets.CLOUDINARY_NAME }}
CLOUDINARY_API_KEY=${{ secrets.CLOUDINARY_API_KEY }}
CLOUDINARY_API_SECRET=${{ secrets.CLOUDINARY_API_SECRET }}
ELASTICSEARCH_URI=${{ secrets.ELASTICSEARCH_URI }}
EOF
- name: Build
run: npm run build --if-present
- name: Restart API server
run: pm2 restart devshop-api --update-env || pm2 start npm --name "devshop-api" -- run server-production