From 78f8c35b038b37e46ff5718280d2fc28af617a45 Mon Sep 17 00:00:00 2001 From: maxime Date: Fri, 16 Feb 2024 21:48:50 +0100 Subject: [PATCH] fix ci --- .eslintrc.cjs | 2 +- ci/.drone.yml | 71 ++++++++++++++++++--------------------- ci/build_and_deploy_to.sh | 3 +- ci/deploy.sh | 2 +- index.html | 2 +- vite.config.ts | 2 +- 6 files changed, 39 insertions(+), 43 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 3961d0a..e2c5b87 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,6 +1,6 @@ module.exports = { root: true, - env: { browser: true, es2023: true }, + env: { browser: true, es2021: true }, extends: [ "eslint:recommended", "plugin:@typescript-eslint/recommended", diff --git a/ci/.drone.yml b/ci/.drone.yml index 608ab78..9d9b989 100644 --- a/ci/.drone.yml +++ b/ci/.drone.yml @@ -3,45 +3,40 @@ type: docker name: "CI and Deploy on maxou.dev" volumes: - - name: server - temp: {} + - name: server + temp: { } trigger: - event: - - push + event: + - push steps: - - image: node:latest - name: "front CI" - commands: - - npm install - - npm run tsc -# - image: node:latest -# name: "build node" -# volumes: &outputs -# - name: server -# path: /outputs -# depends_on: -# - "front CI" -# commands: -# - curl -L moshell.dev/setup.sh > /tmp/moshell_setup.sh -# - chmod +x /tmp/moshell_setup.sh -# - echo n | /tmp/moshell_setup.sh -# - echo "VITE_API_ENDPOINT=/IQBall/$DRONE_BRANCH/public/api" >> .env.PROD -# - echo "VITE_BASE=/IQBall/$DRONE_BRANCH/public" >> .env.PROD -# - apt update && apt install jq -y -# - -# - BASE="/IQBall/$DRONE_BRANCH/public" OUTPUT=/outputs /root/.local/bin/moshell ci/build_react.msh -## -# - image: eeacms/rsync:latest -# name: Deliver on staging server branch -# depends_on: -# - "prepare php" -# - "build node" -# volumes: *outputs -# environment: -# SERVER_PRIVATE_KEY: -# from_secret: SERVER_PRIVATE_KEY -# commands: -# - chmod +x ci/deploy.sh -# - ci/deploy.sh + - image: node:latest + name: "front CI" + commands: + - npm install + - npm run tsc + + - image: node:latest + name: "build react" + volumes: &outputs + - name: server + path: /outputs + depends_on: + - "front CI" + commands: + - npm run build -- --base=/$DRONE_BRANCH + - mv dist/* /outputs + + + - image: eeacms/rsync:latest + name: Deliver on staging server branch + depends_on: + - "build react" + volumes: *outputs + environment: + SERVER_PRIVATE_KEY: + from_secret: SERVER_PRIVATE_KEY + commands: + - chmod +x ci/deploy.sh + - ci/deploy.sh \ No newline at end of file diff --git a/ci/build_and_deploy_to.sh b/ci/build_and_deploy_to.sh index b0d2924..61c5ecf 100755 --- a/ci/build_and_deploy_to.sh +++ b/ci/build_and_deploy_to.sh @@ -1,8 +1,9 @@ +set -e export OUTPUT=$1 export BASE=$2 -rm -rf $OUTPUT/* +rm -rf "$OUTPUT"/* echo "VITE_API_ENDPOINT=$BASE/api" >> .env.PROD echo "VITE_BASE=$BASE" >> .env.PROD diff --git a/ci/deploy.sh b/ci/deploy.sh index 19aa768..634f7d7 100644 --- a/ci/deploy.sh +++ b/ci/deploy.sh @@ -5,7 +5,7 @@ echo "$SERVER_PRIVATE_KEY" > ~/.ssh/id_rsa chmod 0600 ~/.ssh chmod 0500 ~/.ssh/id_rsa* -SERVER_ROOT=/srv/www/IQBall +SERVER_ROOT=/srv/www/iqball ssh -p 80 -o 'StrictHostKeyChecking=no' iqball@maxou.dev mkdir -p $SERVER_ROOT/$DRONE_BRANCH rsync -avz -e "ssh -p 80 -o 'StrictHostKeyChecking=no'" --delete /outputs/* iqball@maxou.dev:$SERVER_ROOT/$DRONE_BRANCH diff --git a/index.html b/index.html index 00e7b1f..e28377b 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - Vite + React + TS + IQBall
diff --git a/vite.config.ts b/vite.config.ts index 1408a24..8e2f5c5 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -6,7 +6,7 @@ import svgr from "vite-plugin-svgr" // https://vitejs.dev/config/ export default defineConfig({ build: { - target: "es2023", + target: "es2021", }, plugins: [ react(),