From fe17a578b404b121c66c40d126ad9609207ab369 Mon Sep 17 00:00:00 2001 From: xunpod Date: Fri, 28 Jun 2024 12:11:04 +0800 Subject: [PATCH] ci: set server to deploy --- .github/workflows/{pages.yaml => deploy.yaml} | 21 +++++++++++++------ deploy/deploy.sh | 4 ++++ deploy/unzipServer.sh | 10 +++++++++ deploy/upload.sh | 6 ++++++ public/CNAME | 1 - 5 files changed, 35 insertions(+), 7 deletions(-) rename .github/workflows/{pages.yaml => deploy.yaml} (64%) create mode 100644 deploy/deploy.sh create mode 100644 deploy/unzipServer.sh create mode 100644 deploy/upload.sh delete mode 100644 public/CNAME diff --git a/.github/workflows/pages.yaml b/.github/workflows/deploy.yaml similarity index 64% rename from .github/workflows/pages.yaml rename to .github/workflows/deploy.yaml index d1a426bf..553ceac3 100644 --- a/.github/workflows/pages.yaml +++ b/.github/workflows/deploy.yaml @@ -1,4 +1,4 @@ -name: Pages +name: Deploy on: push: @@ -8,7 +8,7 @@ on: branches: - master # default branch jobs: - pages: + build: runs-on: ubuntu-latest permissions: contents: write @@ -34,8 +34,17 @@ jobs: cd ../ - name: Build run: npm run build + - name: Setup SSH Private Key + env: + KEY: ${{ secrets.KEY }} + run: | + mkdir -p ~/.ssh/ + echo "$KEY" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + ssh-keyscan 20.115.186.5 >> ~/.ssh/known_hosts - name: Deploy - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./website + run: | + sudo apt install expect tcl -y + cd ./deploy + chmod +x deploy.sh unzipServer.sh upload.sh + ./deploy.sh diff --git a/deploy/deploy.sh b/deploy/deploy.sh new file mode 100644 index 00000000..89dcf519 --- /dev/null +++ b/deploy/deploy.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +./upload.sh +./unzipServer.sh diff --git a/deploy/unzipServer.sh b/deploy/unzipServer.sh new file mode 100644 index 00000000..7de27c2b --- /dev/null +++ b/deploy/unzipServer.sh @@ -0,0 +1,10 @@ + +#!/usr/bin/expect + +set timeout 10 +spawn ssh aosc@20.115.186.5 +expect "aosc@vmportal001:~$" +send "cd /home/aosc/web\r" +send "rm -rf website\r" +send "unzip -x website.zip\r" +expect eof diff --git a/deploy/upload.sh b/deploy/upload.sh new file mode 100644 index 00000000..44c26ee4 --- /dev/null +++ b/deploy/upload.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +rm -rf website* +pnpm run build +zip -r website.zip ../website/ +scp website.zip aosc@20.115.186.5:/home/aosc/web/ diff --git a/public/CNAME b/public/CNAME deleted file mode 100644 index 06c75497..00000000 --- a/public/CNAME +++ /dev/null @@ -1 +0,0 @@ -website-2023.aosc.io \ No newline at end of file