Skip to content

Commit ab98cf7

Browse files
committed
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
1 parent 2f8f253 commit ab98cf7

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ jobs:
1414
with:
1515
fetch-depth: 0
1616
- run: npm ci && npm run build
17+
env:
18+
GOOGLE_ANALYTICS_TRACKING_ID: ${{ vars.GOOGLE_ANALYTICS_TRACKING_ID }}
1719
- uses: actions/upload-pages-artifact@v3
1820
with:
1921
path: build

docusaurus.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ const config = {
4242
"./src/css/custom.css",
4343
],
4444
},
45+
gtag: process.env.GOOGLE_ANALYTICS_TRACKING_ID && {
46+
trackingID: process.env.GOOGLE_ANALYTICS_TRACKING_ID,
47+
},
4548
},
4649
],
4750
],

0 commit comments

Comments
 (0)