minor styling #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Application | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
name: Deploy Backend and Frontend | |
runs-on: self-hosted | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "20.11.1" | |
- name: Install and Build Frontend | |
working-directory: frontend | |
env: | |
VITE_BACKEND_URL: ${{ secrets.VITE_BACKEND_URL }} | |
run: | | |
npm install | |
npm run build | |
- name: Install and Build Backend | |
working-directory: backend | |
env: | |
MONGODB_URI: ${{ secrets.MONGODB_URI }} | |
JWT_SECRET: ${{ secrets.JWT_SECRET }} | |
run: | | |
npm install | |
npm run build | |
- name: Deploy Frontend | |
run: | | |
rsync -av --delete --exclude='.htaccess' ./frontend/dist/ /var/www/html/yeeter/ | |
- name: Deploy Backend | |
run: | | |
pm2 delete "graphql-server" || true | |
cat <<EOF > ecosystem.config.js | |
module.exports = { | |
apps: [{ | |
name: 'graphql-server', | |
script: './backend/dist/index.js', | |
env: { | |
MONGODB_URI: '${{ secrets.MONGODB_URI }}', | |
JWT_SECRET: '${{ secrets.JWT_SECRET }}', | |
NODE_ENV: 'production' | |
} | |
}] | |
}; | |
EOF | |
pm2 start ecosystem.config.js |