Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Deploy (#68) #69

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 32 additions & 34 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Deploy

on:
pull_request:
types: [closed]
push:
branches:
- master

jobs:
deploy:
if: github.event.pull_request.merged == true || github.ref_name == 'master'
runs-on: ubuntu-latest
env:
TARGET: ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_HOST }}
Expand All @@ -16,8 +16,6 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
ref: "develop"
- name: Setup ssh
run: |
mkdir -p ~/.ssh/ && touch ~/.ssh/known_hosts
Expand All @@ -30,19 +28,19 @@ jobs:
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
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
if [[ $DEPLOY_ASSETS == 'false' && $DEPLOY_SERVER == 'false' && $DEPLOY_CLIENT == 'false' ]]; then
exit 1;
fi
# - 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
# 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
# if [[ $DEPLOY_ASSETS == 'false' && $DEPLOY_SERVER == 'false' && $DEPLOY_CLIENT == 'false' ]]; then
# exit 1;
# fi

- name: Install Dependencies
if: ${{ success() }}
Expand All @@ -55,21 +53,21 @@ jobs:
- 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
# 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"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ build/
dist/
docs/.vuepress/.cache
docs/.vuepress/.temp
scripts/api-key.mjs
scripts/api-key.mjs
scripts/plausible-key
25 changes: 5 additions & 20 deletions scripts/postbuild.mjs
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
import rimraf from "rimraf";
import { mkdir } from 'fs/promises'
import { mkdir } from 'fs/promises';
import fs from "fs-extra";
import path from 'path';
import { tmpdir } from 'os';

const outFolder = 'dist/';

// function buildjs() {
// const outDir = 'dist/';
// const tmpDir = path.resolve(tmpdir(), `mots-flex-js${Date.now()}`);
// return fs.mkdir(outDir, { recursive: true })
// .then(() => Promise.all([
// fs.copy("build/public", path.resolve(tmpDir, "public")),
// fs.copy("build/dico", path.resolve(tmpDir, "dico")),
// fs.copy("build/server.js", path.resolve(tmpDir, "server.js")),
// ]))
// .then(() => wz.mZip.zipFolder(tmpDir, 'dist/mots-flex-js.zip'))
// }


Promise.resolve()
.then(() => rimraf(outFolder))
.then(() => mkdir(outFolder))
.then(() => fs.copy('server/dist', outFolder))
.then(() => fs.copy('client/dist', path.resolve(outFolder, 'public')))
.then(() => rimraf(outFolder))
.then(() => mkdir(outFolder))
.then(() => fs.copy('server/dist', outFolder))
.then(() => fs.copy('client/dist', path.resolve(outFolder, 'public')))



Expand Down
Loading