action: build for main repository

This commit is contained in:
hmol233 2021-09-15 18:28:06 +08:00
parent d98294791b
commit d698965203
No known key found for this signature in database
GPG Key ID: D617A9DAB0C992D5
2 changed files with 25 additions and 2 deletions

View File

@ -25,6 +25,8 @@ jobs:
restore-keys: |
${{ runner.os }}-yarn-
- name: Install and Build
env:
XRAY_DOCS_USE_VITE: "true"
run: |
yarn install
yarn docs:build
@ -33,3 +35,15 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/.vuepress/dist
- name: Build for Main Repository
env:
XRAY_DOCS_MAIN_REPO: "true"
run: |
yarn docs:build
- name: Deploy to main Repository
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/.vuepress/dist
external_repository: XTLS/XTLS.github.io
publish_branch: gh-pages-next

View File

@ -5,6 +5,15 @@ import * as navbar from "./config/navbar";
import * as path from "path";
const isProduction = process.env.NODE_ENV === "production";
const forMainRepo = process.env.XRAY_DOCS_MAIN_REPO === "true";
const useVite = process.env.XRAY_DOCS_USE_VITE === "true";
console.log("environment: \n", process.env);
console.log("base:", forMainRepo ? "/" : "/Xray-docs-next/");
console.log(
"bundler:",
isProduction && !useVite ? "@vuepress/webpack" : "@vuepress/vite"
);
export default defineUserConfig<DefaultThemeOptions>({
theme: path.join(__dirname, "./theme"),
@ -21,7 +30,7 @@ export default defineUserConfig<DefaultThemeOptions>({
],
["@vuepress/plugin-debug", !isProduction],
],
base: "/Xray-docs-next/",
base: forMainRepo ? "/" : "/Xray-docs-next/",
locales: {
"/": {
lang: "zh-CN",
@ -130,5 +139,5 @@ export default defineUserConfig<DefaultThemeOptions>({
extendsMarkdown: (md) => {
md.use(require("markdown-it-footnote"));
},
bundler: isProduction ? "@vuepress/webpack" : "@vuepress/vite",
bundler: isProduction && !useVite ? "@vuepress/webpack" : "@vuepress/vite",
});