-
Notifications
You must be signed in to change notification settings - Fork 2
55 lines (53 loc) · 2.09 KB
/
main.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
name: Deploy Express App
# Controls when the action will run.
on:
# Triggers the workflow on push events but only for the main branch
push:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy using ssh
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
script: |
cd InventoryNest
git pull origin main
# Create config.json file with secrets
echo '{
"development": {
"username": "${{ secrets.DB_USERNAME }}",
"password": "${{ secrets.DB_PASSWORD }}",
"database": "${{ secrets.DB_DATABASE }}",
"host": "${{ secrets.DB_HOST }}",
"dialect": "${{ secrets.DB_DIALECT }}"
},
"test": {
"username": "${{ secrets.DB_USERNAME }}",
"password": "${{ secrets.DB_PASSWORD }}",
"database": "${{ secrets.DB_DATABASE }}",
"host": "${{ secrets.DB_HOST }}",
"dialect": "${{ secrets.DB_DIALECT }}"
},
"production": {
"username": "${{ secrets.DB_USERNAME }}",
"password": "${{ secrets.DB_PASSWORD }}",
"database": "${{ secrets.DB_DATABASE }}",
"host": "${{ secrets.DB_HOST }}",
"dialect": "${{ secrets.DB_DIALECT }}"
}
}' > config/config.json
# Create or overwrite .env file with environment variables
echo "PG_URI=${{ secrets.PG_URI }}" > .env
echo "AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}" >> .env
echo "AWS_SECRET_ACESS_KEY=${{ secrets.AWS_SECRET_ACESS_KEY }}" >> .env
echo "BUCKET_NAME=${{ secrets.BUCKET_NAME }}" >> .env
echo "ADDRESS_API_KEY=${{ secrets.ADDRESS_API_KEY }}" >> .env
# Install dependencies and start the application
npm install --only=prod
pm2 reload InventoryNest || pm2 start server.js --name InventoryNest --watch