From 6355ee931756f6fd51a21e540cc6f935a37aa0d3 Mon Sep 17 00:00:00 2001 From: "Nanashi." Date: Wed, 6 Nov 2024 16:02:20 +0900 Subject: [PATCH] =?UTF-8?q?Add:=20preview=5Fpages=E7=94=A8=E3=81=AEWorkflo?= =?UTF-8?q?w=E3=82=92=E8=BF=BD=E5=8A=A0=20(#2342)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Hiroshiba --- .../DANGEROUS_trigger_preview_pages.yml | 26 +++++++++++++++ .github/workflows/build_preview_pages.yml | 32 +++++++++++++++++++ .gitignore | 3 ++ src/backend/browser/sandbox.ts | 4 +-- 4 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/DANGEROUS_trigger_preview_pages.yml create mode 100644 .github/workflows/build_preview_pages.yml diff --git a/.github/workflows/DANGEROUS_trigger_preview_pages.yml b/.github/workflows/DANGEROUS_trigger_preview_pages.yml new file mode 100644 index 0000000000..d61e7485ae --- /dev/null +++ b/.github/workflows/DANGEROUS_trigger_preview_pages.yml @@ -0,0 +1,26 @@ +name: "Trigger preview-pages' workflow" + +# プレビュー用ページのワークフローを起動する。 +# 詳細: https://github.com/voicevox/preview-pages?tab=readme-ov-file#%E4%BB%95%E7%B5%84%E3%81%BF + +on: + pull_request_target: + types: + - opened + - synchronize + - closed + - reopened + push: + branches: + - main + - project-* + +jobs: + trigger: + runs-on: ubuntu-latest + steps: + - name: Trigger Workflow + run: | + gh workflow run -R voicevox/preview-pages update_pages.yml + env: + GH_TOKEN: ${{ secrets.TRIGGER_PREVIEW_PAGES_TOKEN }} diff --git a/.github/workflows/build_preview_pages.yml b/.github/workflows/build_preview_pages.yml new file mode 100644 index 0000000000..f2e9a049af --- /dev/null +++ b/.github/workflows/build_preview_pages.yml @@ -0,0 +1,32 @@ +name: "Build Preview Pages" + +# プレビュー用ページをビルドする。 +# 詳細: https://github.com/voicevox/preview-pages?tab=readme-ov-file#%E4%BB%95%E7%B5%84%E3%81%BF + +on: + push: + branches: + - main + - project-* + pull_request: + +jobs: + update_pages: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup environment + uses: ./.github/actions/setup-environment + + - name: Build + run: | + npm run storybook:build -- --preview-url ./ --output-dir dist_preview/storybook + npm run browser:build -- --base ./ --outDir dist_preview/editor + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: preview-pages + path: dist_preview diff --git a/.gitignore b/.gitignore index 18efad1c2f..457a55735f 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,6 @@ electron-builder.yml # Storybook storybook-static/ + +# Preview Build Output +dist_preview/ diff --git a/src/backend/browser/sandbox.ts b/src/backend/browser/sandbox.ts index 69552e8b7c..291bbdb1ef 100644 --- a/src/backend/browser/sandbox.ts +++ b/src/backend/browser/sandbox.ts @@ -19,8 +19,8 @@ import { } from "@/type/preload"; import { AssetTextFileNames } from "@/type/staticResources"; -// TODO: base pathを設定できるようにするか、ビルド時埋め込みにする -const toStaticPath = (fileName: string) => `/${fileName}`; +const toStaticPath = (fileName: string) => + `${import.meta.env.BASE_URL}/${fileName}`.replaceAll(/\/\/+/, "/"); // FIXME: asを使わないようオーバーロードにした。オーバーロードも使わない書き方にしたい。 function onReceivedIPCMsg<