-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (50 loc) · 1.56 KB
/
deploy.yml
File metadata and controls
59 lines (50 loc) · 1.56 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 CI Denwa
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-22.04
strategy:
matrix:
node: ['20.x']
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Install pnpm
run: npm install -g pnpm
- name: Set up Node.js
uses: actions/setup-node@v3
with:
cache: 'pnpm'
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm build
- name: SSH into VPS and update code
uses: appleboy/ssh-action@master
with:
port: ${{ secrets.SSH_PORT }}
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_DEPLOY_KEY }}
script_stop: true
script: |
set -e
if [ ! -d "/opt/app/http-server" ]; then
git clone git@github.com:Project-DENWA/http-server.git /opt/app/http-server
fi
cd /opt/app/http-server
git fetch origin main
git reset --hard origin/main
echo "${{ secrets.PRODUCTION_ENV_CONTENTS }}" > /opt/app/http-server/.production.env
docker compose --env-file .production.env down
docker compose --env-file .production.env pull
docker system prune -af
docker compose --env-file .production.env up -d --build
docker ps -a