This repository has been archived by the owner on Jul 30, 2023. It is now read-only.
update migration #23
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 Frontend app to EC2 | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
check-version: | |
name: Check If Version Bumped | |
runs-on: ubuntu-latest | |
outputs: | |
changed: ${{ steps.check.outputs.changed }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Check if version has been updated | |
id: check | |
uses: EndBug/version-check@v2 | |
with: | |
diff-search: true | |
file-name: 'Movie-Night-Bot-Website/bot-dashboard/package.json' | |
- name: Log changes | |
if: steps.check.outputs.changed == 'true' | |
run: 'echo "Update in version: ${{steps.check.outputs.changed}}"' | |
deploy_if_updated: | |
name: Deploy to Prod | |
runs-on: ubuntu-latest | |
needs: check-version | |
if: needs.check-version.outputs.changed == 'true' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Deploy to EC2 | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ${{ secrets.EC2_USER }} | |
key: ${{ secrets.EC2_PRIVATE_KEY }} | |
port: 22 | |
script: | | |
export NODE_ENV=production | |
cd /home/ec2-user/projects/Movie-Night-Discord-Bot | |
git pull --rebase --autostash | |
cd /home/ec2-user/projects/Movie-Night-Discord-Bot/Movie-Night-Bot-Website/backend/ | |
npm install --production --silent | |
pm2 restart app.js | |
cd /home/ec2-user/projects/Movie-Night-Discord-Bot/Movie-Night-Bot-Website/bot-dashboard/ | |
npm install --production --silent | |
sudo npm run build | |
sudo service nginx restart |