diff --git a/.drone.yml b/.drone.yml index a4ec590..dd372bf 100644 --- a/.drone.yml +++ b/.drone.yml @@ -7,6 +7,11 @@ platform: os: linux arch: amd64 +volumes: + - name: debian-dist + host: + path: /home/debian/dist + steps: - name: build image: node:23-alpine @@ -23,23 +28,10 @@ steps: - cp -r public .next/standalone - cp -r .next/static .next/standalone/.next - cd .next/standalone - - zip -r ./learn-languages.zip ./* - - - name: transfer file - image: appleboy/drone-scp - settings: - host: - from_secret: ssh_host - username: - from_secret: ssh_username - password: - from_secret: ssh_password - port: 22 - target: /home/debian - source: - - ./learn-languages.zip - rm_target: true - debug: true + - zip -r /dist/learn-languages.zip ./* + volumes: + - name: debian-dist + path: /dist - name: deploy image: appleboy/drone-ssh @@ -57,7 +49,7 @@ steps: script: - cd ~/ - rm -rf learn-languages/* learn-languages/.* - - unzip -d learn-languages learn-languages.zip + - unzip -d learn-languages dist/learn-languages.zip - cd learn-languages - npm i - | @@ -70,3 +62,7 @@ steps: fi - pm2 save debug: true + +trigger: + branch: + - main \ No newline at end of file diff --git a/a.yml b/a.yml new file mode 100644 index 0000000..d673b16 --- /dev/null +++ b/a.yml @@ -0,0 +1,153 @@ +kind: pipeline +name: build-and-package +platform: + os: linux + arch: amd64 + +volumes: + - name: shiro + host: + path: /drone/tmp/shiro + - name: shiro-dist + host: + path: /drone/tmp/shiro-dist + - name: shiro-env + host: + path: /home/innei/docker-compose/drone/public/shiro/.env + + - name: node_modules_cache + host: + path: /drone/tmp/cache + - name: cache + host: + path: /drone/tmp/shiro_next_cache + +steps: + - name: restore-cache + image: drillster/drone-volume-cache + settings: + restore: true + mount: + - ./node_modules + volumes: + - name: node_modules_cache + path: /cache + + - name: build + image: node:20-alpine + environment: + NODE_OPTIONS: --max_old_space_size=4096 + NEXT_TELEMETRY_DISABLED: 1 + commands: + - 'npm i -g pnpm' + - 'pnpm install --no-frozen-lockfile' + - 'npm run build:ci' + + depends_on: + - restore-cache + volumes: + - name: shiro-env + path: /drone/src/.env + - name: cache + path: /drone/src/.next + + - name: rebuild-cache + image: drillster/drone-volume-cache + settings: + rebuild: true + mount: + - ./node_modules + volumes: + - name: node_modules_cache + path: /cache + + depends_on: + - build + + - name: package + image: node:20-alpine + commands: + - 'pwd' + - 'ls -a' + - 'ls .next' + - 'apk add zip' + - 'sh ./standalone-bundle.sh' + volumes: + - name: shiro-dist + path: /drone/src/assets + - name: cache + path: /drone/src/.next + + depends_on: + - build + +trigger: + branch: + - main + event: + include: + - push +--- +kind: pipeline +name: deploy +platform: + os: linux + arch: amd64 + +volumes: + - name: shiro-dist + host: + path: /drone/tmp/shiro-dist + +steps: + - name: transfer file + image: appleboy/drone-scp + settings: + host: + from_secret: ssh_host + username: + from_secret: ssh_username + key: + from_secret: ssh_key + port: 22 + target: /home/deploy/shiro + source: + - assets/release.zip + rm_target: true + strip_components: 1 + debug: true + volumes: + - name: shiro-dist + path: /drone/src/assets + + - name: deploy + image: appleboy/drone-ssh + settings: + host: + from_secret: ssh_host + username: + from_secret: ssh_username + key: + from_secret: ssh_key + port: 22 + script: + - '\npm install --os=linux --cpu=x64 sharp --registry=https://registry.npmmirror.com' + - cd ~/shiro + - unzip -o release.zip + - rm release.zip + - ls + - cd standalone + - cp -r ~/node_modules/sharp ./node_modules + - ~/.n/bin/pm2 restart ecosystem.config.js + debug: true + depends_on: + - transfer file + +depends_on: + - build-and-package +trigger: + branch: + - main + event: + include: + - push