Skip to content

Merge pull request #207 from webduinoio/bug/8106 #39

Merge pull request #207 from webduinoio/bug/8106

Merge pull request #207 from webduinoio/bug/8106 #39

Workflow file for this run

name: Deploy to Custom Server Tutor Prod
on:
push:
branches:
- tutor
jobs:
deploy:
runs-on: ubuntu-latest
env:
AWS_S3_BUCKET_NAME: webduino-chat
steps:
- uses: actions/checkout@master
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.tool-versions'
- name: Cache npm packages
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-
- name: Install Dependencies
run: npm ci
- name: Build Application
run: npm run build
- name: Clean old backups
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: ${{ secrets.PORT }}
script: |
cd /mnt/i32g-nfs/pluto-frontend
ls -dt backup_* | tail -n +4 | xargs rm -rf
- name: Backup target directory
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: ${{ secrets.PORT }}
script: |
TIMESTAMP=$(date +'%Y%m%d%H%M%S')
BACKUP_DIR="/mnt/i32g-nfs/pluto-frontend/backup_public_$TIMESTAMP"
mkdir -p $BACKUP_DIR
cp -r /mnt/i32g-nfs/pluto-frontend/public/* $BACKUP_DIR
- name: Clean target directory
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: ${{ secrets.PORT }}
script: |
rm -rf /mnt/i32g-nfs/pluto-frontend/public/*
- name: Upload App to Server
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: ${{ secrets.PORT }}
source: 'dist/*'
target: '/mnt/i32g-nfs/pluto-frontend/public'
strip_components: 1