Skip to content

Test Deploy

Test Deploy #39

Workflow file for this run

name: Deploy
on:
pull_request:
branches:
- develop
jobs:
deploy:
runs-on: ubuntu-latest
# if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- 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
- name: Deploy
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"
SERVER: "~/motsflex-save/server.js"
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,SERVER
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