-
Notifications
You must be signed in to change notification settings - Fork 3
109 lines (85 loc) · 2.54 KB
/
build-and-deploy.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Spincord CI/CD
on:
push:
branches:
- main
jobs:
# lint typescript and enforce style
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: yarn install
- name: Lint source code
run: yarn lint
# run all unit tests
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: yarn install
- name: Run unit tests
run: yarn test
# check if typescript source compiles successfully without errors
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: yarn
- name: Build
run: yarn build
# Deploy spincord to digital ocean droplet
deploy:
needs: [lint, test, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Start deployment
uses: bobheadxi/deployments@v1
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: release
- name: Install dependencies
run: yarn install
- name: Build production javascipt
env:
PRODUCTION_DOTENV: ${{ secrets.PRODUCTION_DOTENV }}
run: |
yarn build
echo "${PRODUCTION_DOTENV}" > "dist/.env"
- name: Register slash commands
run: cd dist; node utils/deploy_commands; cd ..
- name: SSH deploy
uses: easingthemes/[email protected]
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SOURCE: "dist/"
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
TARGET: ${{ secrets.REMOTE_TARGET }}
- name: Set up and restart production server
uses: garygrossgarten/github-action-ssh@release
with:
command: pm2 restart spincord/app.js --update-env || pm2 start spincord/app.js --update-env
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
privateKey: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Update deployment status
uses: bobheadxi/deployments@v1
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
env: ${{ steps.deployment.outputs.env }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}