diff --git a/.github/deploy.yml b/.github/deploy.yml new file mode 100644 index 0000000..678d914 --- /dev/null +++ b/.github/deploy.yml @@ -0,0 +1,23 @@ +name: Deploy + +on: + pull_request: + types: [ closed ] + branches: + - release + +jobs: + deploy: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + environment: Deployment + steps: + - uses: actions/checkout@v4 + - run: npm install + - run: ./deploy.sh + env: + BUILD_MODE: ${{ vars.BUILD_MODE }} + DEPLOYMENT_RES_PATH: ${{ vars.DEPLOYMENT_RES_PATH }} + DEPLOYMENT_SERVER: ${{ vars.DEPLOYMENT_SERVER }} + DEPLOYMENT_USER: ${{ vars.DEPLOYMENT_USER }} + SSH_KEY: ${{ secrets.SSH_KEY }} \ No newline at end of file diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 0000000..079a4d5 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +set -e + +SCRIPT_DIR=$(pwd) +ROOT_DIR=$SCRIPT_DIR +BUILD_DIR=$SCRIPT_DIR/dist + +echo "==== Alice Deployment ====" +echo "" +echo "--> Compiling WASM binary..." +echo "" + +wasm-pack build + +echo "" +echo "--> Compiling frontend..." +echo "" + +npm run build:$BUILD_MODE + +echo "" +echo "--> Uploading to deployment server..." +echo "" + +ssh-add - <<< "${SSH_KEY}" +ssh $DEPLOYMENT_USER@$DEPLOYMENT_SERVER "rm -rf $DEPLOYMENT_RES_PATH/*" +scp -r dist $DEPLOYMENT_USER@$DEPLOYMENT_SERVER:$DEPLOYMENT_RES_PATH + +echo -e "\033[1;32m" +echo "Done ^-^" +echo -e "\033[0m" \ No newline at end of file