Skip to content

Fix gitignore

Fix gitignore #15

name: Auto-update app on production VPS
on:
pull_request:
types:
- closed
branches:
- main
jobs:
deploy:
if: github.event.pull_request.merged == true
name: Deploy latest updates to production server
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Run commands on remote VPS server
env:
PRIVATE_KEY: ${{secrets.PRIVATE_KEY}}
HOSTNAME: ${{secrets.PROD_HOST}}
USER_NAME: ${{secrets.PROD_USER}}
GITHUB_TOKEN: ${{secrets.SMTP_DEPLOYMENT_KEY}}
run: |
echo "$PRIVATE_KEY" > private_key && chmod 600 private_key
ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} '
echo 'Script execution started'
cd /var/www/
echo 'Stopping application'
pm2 stop all
echo 'Removing old project'
sudo rm -r -f ./smtp_server/
mkdir smtp_server
cd smtp_server
echo 'Initialization empty local repository'
git init
echo 'Adding remote repository'
git remote add origin https://$GITHUB_TOKEN@github.com/yunusmi/smtp_server.git
git pull origin main
if [ $? -eq 0 ]; then
echo 'GIT pull success'
else
echo 'GIT pull failure'
exit 1;
fi
echo 'Install nodejs dependencies'
npm ci
echo 'Finished installing nodejs dependencies'
echo 'Compiling from TS'
npx tsc
echo 'Compiling has done successfully'
echo 'Starting application'
npx cross-env NODE_ENV=production pm2 start ./dist/app.js
echo 'Application has started successfully'
pm2 save
echo 'Script execution completed'
'