Skip to content

Test Deploy (#70)

Test Deploy (#70) #87

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: Determine Deployment Type
# if: ${{ success() }}
# run: |
# echo "DEPLOY_ASSETS=${{ contains(toJson(github.event.pull_request.labels.*.name), 'deploy:assets') }}" >> $GITHUB_ENV
# echo "DEPLOY_SERVER=${{ contains(toJson(github.event.pull_request.labels.*.name), 'deploy:server') }}" >> $GITHUB_ENV
# echo "DEPLOY_CLIENT=${{ contains(toJson(github.event.pull_request.labels.*.name), 'deploy:client') }}" >> $GITHUB_ENV
# if [[ $DEPLOY_ASSETS == 'false' && $DEPLOY_SERVER == 'false' && $DEPLOY_CLIENT == 'false' ]]; then
# exit 1;
# fi
- name: Install Dependencies
if: ${{ success() }}
run: npm ci
- name: Build
if: ${{ success() }}
run: npm run build
- name: Deploy
if: ${{ success() }}
run: |
# if [ "$DEPLOY_ASSETS" = 'true' ]; then
# echo "Deploying JS assets"
# ssh -i $KEY $TARGET "rm -rf $ASSETS && mkdir -p $ASSETS"
# scp -i $KEY -r dist/public/assets/* "$TARGET:$ASSETS"
# scp -i $KEY -r dist/public/index.html "$TARGET:$INDEX_HTML"
# fi
# if [ "$DEPLOY_CLIENT" = 'true' ]; then
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/assets"
# fi
# if [ "$DEPLOY_SERVER" = 'true' ]; then
echo "Deploying server code"
scp -i $KEY -r dist/server.js "$TARGET:$SERVER"
# fi
- name: Cleanup
run: "rm -f $KEY && rm -rf ~/.ssh"