-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (49 loc) · 1.39 KB
/
ci.yml
File metadata and controls
57 lines (49 loc) · 1.39 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
name: CI/CD
on:
pull_request:
push:
workflow_dispatch:
jobs:
test:
name: Run tests
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
deploy:
name: Deploy to Production
runs-on: ubuntu-latest
needs: [test]
if: ${{ github.event_name != 'pull_request' && (github.ref_name == 'main' || github.ref_name == 'master') }}
timeout-minutes: 30
concurrency:
group: sg-stats-server-prod
cancel-in-progress: true
steps:
- name: Deploy over SSH
uses: appleboy/ssh-action@v1.2.2
env:
APP_DIR: ${{ secrets.CD_APP_DIR }}
BRANCH: ${{ github.ref_name }}
with:
host: ${{ secrets.CD_SSH_HOST }}
username: ${{ secrets.CD_SSH_USER }}
key: ${{ secrets.CD_SSH_PRIVATE_KEY }}
port: ${{ secrets.CD_SSH_PORT }}
script_stop: true
command_timeout: 30m
envs: APP_DIR,BRANCH
script: |
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
bash "$APP_DIR/deploy/remote-deploy.sh" "$APP_DIR" "$BRANCH"