From ab98cf7af3943ea278a7514aad9ca90760df0223 Mon Sep 17 00:00:00 2001 From: chelproc Date: Fri, 11 Jul 2025 20:08:05 +0900 Subject: [PATCH] Add GOOGLE_ANALYTICS_TRACKING_ID environment variable to deploy workflow - Pass repository variable GOOGLE_ANALYTICS_TRACKING_ID as environment variable during npm run build - Configure Docusaurus to use Google Analytics when the environment variable is set --- .github/workflows/deploy.yml | 2 ++ docusaurus.config.js | 3 +++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f9e31a351..73f14910e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -14,6 +14,8 @@ jobs: with: fetch-depth: 0 - run: npm ci && npm run build + env: + GOOGLE_ANALYTICS_TRACKING_ID: ${{ vars.GOOGLE_ANALYTICS_TRACKING_ID }} - uses: actions/upload-pages-artifact@v3 with: path: build diff --git a/docusaurus.config.js b/docusaurus.config.js index b51dd6a1f..f55721190 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -42,6 +42,9 @@ const config = { "./src/css/custom.css", ], }, + gtag: process.env.GOOGLE_ANALYTICS_TRACKING_ID && { + trackingID: process.env.GOOGLE_ANALYTICS_TRACKING_ID, + }, }, ], ],