Skip to content

Commit

Permalink
use a plugin and run all scripts on server
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo-Nicolle committed Feb 11, 2024
1 parent a09e699 commit 4caf751
Showing 1 changed file with 38 additions and 30 deletions.
68 changes: 38 additions & 30 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ on:
- develop

env:
PUBLIC: "~/motsflex-save/public"
ASSETS: "$PUBLIC/assets"
INDEX_HTML: "$PUBLIC/index.html"
DICOS: "~/dicos"
SERVER: "~/motsflex-save/server.js"
SSH_TARGET: ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_HOST }}

Expand All @@ -33,30 +29,42 @@ jobs:
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
# - name: Install Dependencies
# if: ${{ success() }}
# run: npm install

# - name: Build
# if: ${{ success() }}
# run: npm run build

steps:
- name: Deploy
if: ${{ success() }}
run: |
if [[ "${{ env.DEPLOY_ASSETS }}" == 'true' ]]; then
echo "Deploying JS assets"
ssh ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_HOST }} "rm -rf $ASSETS && mkdir -p $ASSETS"
# scp -r dist/public/assets $SSH_TARGET:$ASSETS
# scp -r dist/public/index.html $SSH_TARGET:$INDEX_HTML
fi
# if [[ "${{ env.DEPLOY_CLIENT }}" == 'true' ]]; then
# echo "Deploying full client"
# ssh $SSH_TARGET "rm -rf $PUBLIC && mkdir -p $PUBLIC"
# scp -r dist/public $SSH_TARGET:$PUBLIC
# ssh $SSH_TARGET "cp $DICOS/*.zip $ASSETS"
# fi
# if [[ "${{ env.DEPLOY_SERVER }}" == 'true' ]]; then
# echo "Deploying server code"
# scp -r dist/server.js $SSH_TARGET:$SERVER
# fi
uses: appleboy/ssh-action@master
env:
DEPLOY_ASSETS: "${{ env.DEPLOY_ASSETS }}"
DEPLOY_SERVER: "${{ env.DEPLOY_SERVER }}"
DEPLOY_CLIENT: "${{ env.DEPLOY_CLIENT }}"
PUBLIC: "~/motsflex-save/public"
ASSETS: "$PUBLIC/assets"
INDEX_HTML: "$PUBLIC/index.html"
DICOS: "~/dicos"

with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
envs: DEPLOY_ASSETS,DEPLOY_SERVER,DEPLOY_CLIENT,PUBLIC,ASSETS,INDEX_HTML,DICOS
script: |
cd /tmp/mots-fleches
git pull origin develop
npm install
npm run build
if [ "$DEPLOY_ASSETS" = 'true' ]; then
echo "Deploying JS assets"
rm -rf $ASSETS && mkdir -p $ASSETS"
cp -r dist/public/assets $ASSETS
cp -r dist/public/index.html $INDEX_HTML
fi
if [ "$DEPLOY_CLIENT" = 'true' ]; then
echo "Deploying full client"
rm -rf $PUBLIC && mkdir -p $PUBLIC
cp -r dist/public $PUBLIC
cp $DICOS/*.zip $ASSETS
fi
if [ "$DEPLOY_SERVER" = 'true' ]; then
echo "Deploying server code"
cp -r dist/server.js $SERVER
fi

0 comments on commit 4caf751

Please sign in to comment.