-
Notifications
You must be signed in to change notification settings - Fork 2
73 lines (68 loc) · 2.56 KB
/
deploy_development.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
name: Deploy to Development
on:
push:
branches: [development]
jobs:
deploy:
name: Deploy Process
runs-on: ubuntu-latest
environment: development
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install Dependencies
run: corepack enable && yarn install --immutable
- name: Run unit tests
run: yarn test
- name: Build
run: yarn build
- name: Generate .env file
run: |
touch .env
echo NODE_ENV=development >> .env
echo GOOGLE_ACCOUNT_CLIENT=${{ secrets.GOOGLE_ACCOUNT_CLIENT }} >> .env
echo GOOGLE_ACCOUNT_SECRET=${{ secrets.GOOGLE_ACCOUNT_SECRET }} >> .env
echo GOOGLE_ACCOUNT_TOKEN=${{ secrets.GOOGLE_ACCOUNT_TOKEN }} >> .env
echo GOOGLE_ACCOUNT_OAUTH_REDIRECT=${{ vars.GOOGLE_ACCOUNT_OAUTH_REDIRECT }} >> .env
echo SLACK_APP_TOKEN=${{ secrets.SLACK_APP_TOKEN }} >> .env
echo SLACK_OAUTH_TOKEN=${{ secrets.SLACK_OAUTH_TOKEN }} >> .env
echo SLACK_SIGNING_SECRET=${{ secrets.SLACK_SIGNING_SECRET }} >> .env
echo DEPLOY_COMMIT_SHA=${{ github.sha }} >> .env
- name: Move files to dist
run: |
mv .env ./dist/
mv ecosystem.config.js ./dist/
- name: Copy files to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.REMOTE_KEY }}
source: dist/
target: ~/minerva-dev/
strip_components: 1
- name: Start pm2 process and monitor startup
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.REMOTE_KEY }}
script: |
cd ~/minerva-dev
echo "Starting the application with PM2."
pm2 start ecosystem.config.js
echo "Waiting for the application to stabilize."
sleep 10
# Check if PM2 started the application successfully
echo "Checking PM2 process status..."
if pm2 jlist | jq -e 'any(.pm2_env.status == "online")' > /dev/null; then
echo "PM2 application is running."
exit 0
else
echo "PM2 application has failed to start."
exit 1
fi