-
Notifications
You must be signed in to change notification settings - Fork 13
76 lines (72 loc) · 1.84 KB
/
socios-auth2.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
name: "socios-oauth2 CI"
on:
push:
branches:
- main
- staging
pull_request:
branches:
- "*"
workflow_dispatch:
env:
PROJ_PATH: socios-oauth2
DEPLOY_URL: https://socios-oauth2.tokenscript.org/
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 18
cache: "npm"
cache-dependency-path: ${{ env.PROJ_PATH }}/package-lock.json
- run: |
echo -n "Node version: "
node -v
echo -n "Npm version: "
npm -v
- name: build
run: |
cd "${PROJ_PATH}"
npm ci
npm run build
- uses: actions/upload-artifact@v3
with:
name: socios-oauth2
path: ${{ env.PROJ_PATH }}/dist/
deploy:
runs-on: ubuntu-latest
environment:
name: socios-oauth2
url: ${{ env.DEPLOY_URL }}
needs:
- build
if: ${{ contains(
fromJson('["push", "workflow_dispatch"]'),
github.event_name) &&
contains(
fromJson('["staging"]'),
github.ref_name)
}}
steps:
- uses: actions/download-artifact@v3
with:
name: socios-oauth2
path: ${{ env.PROJ_PATH }}/dist/
- name: Deploy to EC2
uses: easingthemes/ssh-deploy@v4
with:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
REMOTE_HOST: 54.177.203.8
REMOTE_USER: ubuntu
ARGS: "-aPz --delete"
SOURCE: "${{ env.PROJ_PATH }}/dist/"
TARGET: /opt/services/socios-oauth2/
SCRIPT_AFTER: |
sudo systemctl restart socios-oauth2
- name: check deploy
run: |
for i in $(seq 15); do
curl -sfL --connect-timeout 30 "${DEPLOY_URL}" && exit || sleep 5
done && exit 1