Prepare for deploy
This commit is contained in:
parent
3f3bd797c4
commit
d8eb3bcef5
2 changed files with 45 additions and 15 deletions
|
@ -18,23 +18,19 @@ jobs:
|
||||||
with:
|
with:
|
||||||
node-version: 19
|
node-version: 19
|
||||||
|
|
||||||
- name: Install rsync
|
env:
|
||||||
run: |
|
SSH_PRIVATE_KEY: ${{secrets.SSH_KEY}}
|
||||||
apt-get update
|
SSH_KNOWN_HOSTS: ${{secrets.SSH_KNOWN_HOSTS}}
|
||||||
apt-get install -y rsync
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install PM2
|
||||||
run: npm install
|
run: npm i -g pm2
|
||||||
|
|
||||||
- name: Build app
|
|
||||||
run: npm run build
|
|
||||||
|
|
||||||
- name: Add Deploy Key to SSH
|
- name: Add Deploy Key to SSH
|
||||||
run: |
|
run: |
|
||||||
mkdir ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.SSH_KEY }}" >> ~/.ssh/id_ed25519_embroideryviewer
|
echo "${{ secrets.SSH_KEY }}" >> ./deploy.key
|
||||||
chmod 400 ~/.ssh/id_ed25519_embroideryviewer
|
sudo chmod 600 ./deploy.key
|
||||||
echo -e "Host embroideryviewer\n\tUser embroideryviewer\n\tHostname 45.76.5.44\n\tIdentityFile ~/.ssh/id_ed25519_embroideryviewer\n\tStrictHostKeyChecking No" >> ~/.ssh/config
|
echo "${{ secrets.SSH_KNOWN_HOSTS}}" > ~/.ssh/known_hosts
|
||||||
|
|
||||||
- name: Upload changes to server
|
- name: Deploy
|
||||||
run: rsync -avz --progress dist/ embroideryviewer:web/prod
|
run: env $(cat .env | grep -v \"#\" | xargs) pm2 deploy ecosystem.config.cjs production
|
||||||
|
|
34
ecosystem.config.cjs
Normal file
34
ecosystem.config.cjs
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
module.exports = {
|
||||||
|
apps: [
|
||||||
|
{
|
||||||
|
name: 'embroidery-viewer',
|
||||||
|
script: './build/index.js',
|
||||||
|
time: true,
|
||||||
|
instances: 1,
|
||||||
|
autorestart: true,
|
||||||
|
max_restarts: 50,
|
||||||
|
watch: false,
|
||||||
|
max_memory_restart: '1G',
|
||||||
|
env: {
|
||||||
|
NODE_ENV: 'production',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
deploy: {
|
||||||
|
production: {
|
||||||
|
user: 'deployer',
|
||||||
|
host: '45.76.5.44',
|
||||||
|
key: 'deploy.key',
|
||||||
|
ref: 'origin/main',
|
||||||
|
repo: 'git@git.leomurca.xyz:leomurca/embroidery-viewer.git',
|
||||||
|
path: '/home/deployer/embroidery-viewer',
|
||||||
|
'pre-deploy': 'rm package-lock.json && npm i',
|
||||||
|
'post-deploy':
|
||||||
|
'npm run build && pm2 reload ecosystem.config.cjs --only acelera-alagoas-prod --env production && pm2 save',
|
||||||
|
env: {
|
||||||
|
PORT: 7017,
|
||||||
|
NODE_ENV: 'production',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
Loading…
Add table
Reference in a new issue