From 1d03100dccbf154a41cd794df24bb00d73fdb7aa Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Tue, 4 Apr 2023 21:41:06 -0400 Subject: [PATCH] Add building for handbook also implement linting, ci for handbook, and change `.editorconfig` to do 2-line for .yml --- .editorconfig | 2 +- .github/workflows/handbook.yml | 79 ++++++++++++++++++++++++++++++++++ src/handbook/vite.config.ts | 6 ++- 3 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/handbook.yml diff --git a/.editorconfig b/.editorconfig index dcc46b748..1c7bcce3d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,5 +10,5 @@ max_line_length = 120 tab_width = 4 trim_trailing_whitespace = true -[{*.json,*.xml}] +[{*.json,*.xml,*.yml}] indent_size = 2 diff --git a/.github/workflows/handbook.yml b/.github/workflows/handbook.yml new file mode 100644 index 000000000..9700ee4e4 --- /dev/null +++ b/.github/workflows/handbook.yml @@ -0,0 +1,79 @@ +name: "Handbook" + +on: + workflow_dispatch: ~ + push: + paths: + - "src/handbook/**.tsx" + branches: + - "development" + - "unstable" + pull_request: + paths: + - "src/handbook/**.tsx" + types: + - opened + - synchronize + - reopened + +jobs: + Lint-Code: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Node + uses: actions/setup-node@v2 + with: + node-version: '17' + - name: Cache node modules + uses: actions/cache@v2 + with: + path: | + ~/.npm + ~/.cache + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Install dependencies + run: npm install + - name: Run linter + run: npm run lint + + - run: git config --global user.name "github-actions" + - run: git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + - name: Commit changes + if: ${{ github.event_name == 'push' }} + run: git add -u && git commit -m "Lint Code [skip actions]" || true + - name: Push changes + if: ${{ github.event_name == 'push' }} + run: git push --set-upstream --force origin ${{ github.ref }} + + Build-Handbook: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - run: cd src/handbook + - name: Setup Node + uses: actions/setup-node@v2 + with: + node-version: '17' + - name: Cache node modules + uses: actions/cache@v2 + with: + path: | + ~/.npm + ~/.cache + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Install dependencies + run: npm install + - name: Build handbook + run: npm run build + - name: Upload build + uses: actions/upload-artifact@v3 + with: + name: Handbook + path: src/handbook/dist/*.html diff --git a/src/handbook/vite.config.ts b/src/handbook/vite.config.ts index 2e4f4a3a1..0059d4eca 100644 --- a/src/handbook/vite.config.ts +++ b/src/handbook/vite.config.ts @@ -3,13 +3,15 @@ import { defineConfig } from "vite"; import react from "@vitejs/plugin-react-swc"; -import viteSvgr from "vite-plugin-svgr"; import tsconfigPaths from "vite-tsconfig-paths"; +import viteSvgr from "vite-plugin-svgr"; +import { viteSingleFile } from "vite-plugin-singlefile"; + import postcss from "./cfg/postcss.config.js"; // https://vitejs.dev/config/ export default defineConfig({ - plugins: [ react(), tsconfigPaths(), viteSvgr() ], + plugins: [ react(), tsconfigPaths(), viteSvgr(), viteSingleFile() ], css: { postcss } });