Skip to content

Merge pull request #71 from Leo-Nicolle/develop #88

Merge pull request #71 from Leo-Nicolle/develop

Merge pull request #71 from Leo-Nicolle/develop #88

Workflow file for this run

name: Deploy
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
env:
TARGET: ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_HOST }}
KEY: /tmp/private-key
DIR: ~/motsflex
DICOS: ~/dicos
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Setup
run: |
mkdir -p ~/.ssh/ && touch ~/.ssh/known_hosts
ssh-keyscan ${{ secrets.SERVER_HOST }} >> ~/.ssh/known_hosts
echo "${{ secrets.SSH_PRIVATE_KEY }}" > $KEY
chmod 600 $KEY
echo "PUBLIC=$DIR/public" >> $GITHUB_ENV
echo "SERVER=${{ env.DIR }}/server.js" >> $GITHUB_ENV
echo "ASSETS=${{ env.DIR }}/public/assets" >> $GITHUB_ENV
echo "INDEX_HTML=${{ env.DIR }}/public/index.html" >> $GITHUB_ENV
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
- name: Install Dependencies
if: ${{ success() }}
run: npm ci
- name: Build
if: ${{ success() }}
run: npm run build
- name: Deploy
if: ${{ success() }}
run: |
echo "Deploying full client"
ssh -i $KEY $TARGET "rm -rf $PUBLIC && mkdir -p $PUBLIC"
scp -i $KEY -r dist/public/* "$TARGET:$PUBLIC"
ssh -i $KEY $TARGET "cp $DICOS/*.zip $PUBLIC"
echo "Deploying server code"
scp -i $KEY -r dist/server.js "$TARGET:$SERVER"
- name: Cleanup
run: "rm -f $KEY && rm -rf ~/.ssh"