删除三个已弃用的 GitHub Actions 工作流文件 (deploy_docs_pages.yml, demo_site_deploy.yml, custom_deploy.yml),这些工作流已不再使用。 同时更新 web/config.js 中的生产环境检测逻辑,使其同时识别 'prod' 和 'production' 环境变量值,提高配置的灵活性。
This commit is contained in:
@@ -1,69 +0,0 @@
|
||||
name: custom-deploy-your-server
|
||||
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
|
||||
jobs:
|
||||
build-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "20.x"
|
||||
|
||||
- name: Set up Golang
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: "1.24"
|
||||
|
||||
- name: Install npm dependencies
|
||||
run: npm ci
|
||||
working-directory: web/
|
||||
|
||||
- name: Run npm build
|
||||
run: echo "BUILD_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENV && export NODE_ENV=prod && npm run build
|
||||
working-directory: web/
|
||||
|
||||
- name: Check build static
|
||||
run: ls dist/ -la
|
||||
working-directory: web/
|
||||
|
||||
- name: Get Release version
|
||||
id: get_version
|
||||
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Update Local Version File
|
||||
run: echo ${{ steps.get_version.outputs.VERSION }} > .release_version
|
||||
|
||||
- name: Install Go modules
|
||||
run: go mod tidy
|
||||
|
||||
- name: Build Go
|
||||
run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o Message-Nest
|
||||
|
||||
- name: Copy files to server
|
||||
uses: appleboy/scp-action@master
|
||||
with:
|
||||
host: ${{ secrets.SERVER_HOST }}
|
||||
port: ${{ secrets.SERVER_PORT }}
|
||||
username: ${{ secrets.SERVER_USERNAME }}
|
||||
password: ${{ secrets.SERVER_PASSWD }}
|
||||
source: "Message-Nest"
|
||||
target: ${{ secrets.REMOTE_TARGER }}
|
||||
|
||||
- name: SSH into server and restart service
|
||||
uses: appleboy/ssh-action@master
|
||||
with:
|
||||
host: ${{ secrets.SERVER_HOST }}
|
||||
port: ${{ secrets.SERVER_PORT }}
|
||||
username: ${{ secrets.SERVER_USERNAME }}
|
||||
password: ${{ secrets.SERVER_PASSWD }}
|
||||
script: |
|
||||
${{ secrets.REMOTE_SCRIPT }}
|
||||
@@ -1,69 +0,0 @@
|
||||
name: deploy-demo-site
|
||||
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
|
||||
jobs:
|
||||
build-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "20.x"
|
||||
|
||||
- name: Set up Golang
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: "1.24"
|
||||
|
||||
- name: Install npm dependencies
|
||||
run: npm ci
|
||||
working-directory: web/
|
||||
|
||||
- name: Run npm build
|
||||
run: export NODE_ENV=prod && npm run build:demo
|
||||
working-directory: web/
|
||||
|
||||
- name: Check build static
|
||||
run: ls dist/ -la
|
||||
working-directory: web/
|
||||
|
||||
- name: Get Release version
|
||||
id: get_version
|
||||
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Update Local Version File
|
||||
run: echo ${{ steps.get_version.outputs.VERSION }} > .release_version
|
||||
|
||||
- name: Install Go modules
|
||||
run: go mod tidy
|
||||
|
||||
- name: Build Go
|
||||
run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o Message-Nest
|
||||
|
||||
- name: Copy files to server
|
||||
uses: appleboy/scp-action@master
|
||||
with:
|
||||
host: ${{ secrets.SERVER_HOST }}
|
||||
port: ${{ secrets.SERVER_PORT }}
|
||||
username: ${{ secrets.SERVER_USERNAME }}
|
||||
password: ${{ secrets.SERVER_PASSWD }}
|
||||
source: "Message-Nest"
|
||||
target: ${{ secrets.REMOTE_DEMO_TARGET }}
|
||||
|
||||
- name: SSH into server and restart service
|
||||
uses: appleboy/ssh-action@master
|
||||
with:
|
||||
host: ${{ secrets.SERVER_HOST }}
|
||||
port: ${{ secrets.SERVER_PORT }}
|
||||
username: ${{ secrets.SERVER_USERNAME }}
|
||||
password: ${{ secrets.SERVER_PASSWD }}
|
||||
script: |
|
||||
${{ secrets.REMOTE_DEMO_SCRIPT }}
|
||||
@@ -1,66 +0,0 @@
|
||||
name: Deploy Docs to GitHub Pages
|
||||
|
||||
on:
|
||||
# 在推送到 main 分支时触发
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
# 允许手动触发
|
||||
workflow_dispatch:
|
||||
|
||||
# 设置 GITHUB_TOKEN 的权限,允许部署到 GitHub Pages
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
# 只允许一个并发部署
|
||||
concurrency:
|
||||
group: pages
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
# 构建任务
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # 如果未启用 lastUpdated,则不需要
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: npm
|
||||
cache-dependency-path: docs/package-lock.json
|
||||
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
working-directory: docs
|
||||
|
||||
- name: Build with VitePress
|
||||
run: npm run docs:build
|
||||
working-directory: docs
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: docs/.vitepress/dist
|
||||
|
||||
# 部署任务
|
||||
deploy:
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
name: Deploy
|
||||
steps:
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// config.js
|
||||
|
||||
const isProduction = process.env.NODE_ENV === 'prod';
|
||||
const isProduction = process.env.NODE_ENV === 'prod' || process.env.NODE_ENV === 'production';
|
||||
|
||||
// 从 window 对象获取路径前缀(由后端注入或通过 API 获取)
|
||||
const getPathPrefix = () => {
|
||||
|
||||
Reference in New Issue
Block a user