Skip to content

Commit

Permalink
chore: 添加服务器部署
Browse files Browse the repository at this point in the history
  • Loading branch information
aisen60 committed Apr 12, 2024
1 parent 3e52854 commit 5093a22
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 28 deletions.
13 changes: 13 additions & 0 deletions .env.deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# # node 环境
# NODE_ENV=production
VITE_BASE=/
#APP 运行环境
VITE_APP_ENV=production
# 是否开启 vconsole
VITE_APP_VCONSOLE_ENABLED=true
# 是否启用 gzip 或 brotli 压缩
# 可选性: gzip | brotli | none
# 如果需要多个,可以使用逗号分隔
VITE_APP_BUILD_COMPRESS=gzip
# 使用压缩时是否删除源文件,默认为 false
VITE_APP_BUILD_COMPRESS_DELETE_ORIGIN_FILE=false
35 changes: 35 additions & 0 deletions .github/workflows/deploy-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Deploy site by main branch to gh pages

on:
workflow_dispatch:
push:
branches: [main]

jobs:
deploy:
runs-on: ubuntu-20.04
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- name: Checkout main branch code
uses: actions/checkout@v3
with:
ref: main

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install dependencies
run: npm install

- name: Build project
run: npm run build

- name: Deploy gh page
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GH_PAGES }}
publish_dir: ./dist
42 changes: 14 additions & 28 deletions .github/workflows/deploy-website.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,23 @@
name: Deploy Site By main Branch
name: Deploy site by main branch to server

on:
workflow_dispatch:
push:
branches: [main]
schedule:
- cron: "0 21 * * *"

jobs:
deploy:
runs-on: ubuntu-20.04
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
main-branch-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout main branch code
uses: actions/checkout@v3
- name: Deploy
uses: appleboy/ssh-action@master
with:
ref: main

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install dependencies
run: npm install

- name: Build project
run: npm run build

- name: Deploy gh page
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GH_PAGES }}
publish_dir: ./dist
host: ${{ secrets.HOST }}
port: ${{ secrets.PORT }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
cd /opt/cxs/vue3-h5-template
git pull origin main
pnpm install
npm run build:deploy
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"build:sit": "npm run type-check && vite build --mode sit",
"build:uat": "npm run type-check && vite build --mode uat",
"build:prod": "npm run type-check && vite build",
"build:deploy": "npm run type-check && vite build --mode deploy",
"preview": "vite preview --port 4173",
"type-check": "vue-tsc --noEmit",
"lint:eslint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
Expand Down

0 comments on commit 5093a22

Please sign in to comment.