Skip to content

Commit 39c0c36

Browse files
authored
Merge pull request #111 from USACE-RMC/fix/disable-gtag-on-previews
Disable Google Analytics on preview builds
2 parents b953ff2 + 287865e commit 39c0c36

3 files changed

Lines changed: 30 additions & 9 deletions

File tree

.github/workflows/ci-build.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
permissions:
88
contents: read
99
pull-requests: write
10+
statuses: write
1011

1112
jobs:
1213
build:
@@ -35,8 +36,21 @@ jobs:
3536
const touchesDocs = files.some(f => f.filename.startsWith('docs/'));
3637
if (touchesDocs) return; // docs PRs are handled by stage-progression.yml
3738
39+
// Flip the review-workflow commit status to success so branch
40+
// protection allows merge. This is the non-docs counterpart to
41+
// stage-progression.yml's status-setting for docs PRs.
42+
const headSha = context.payload.pull_request.head.sha;
43+
await github.rest.repos.createCommitStatus({
44+
owner: context.repo.owner,
45+
repo: context.repo.repo,
46+
sha: headSha,
47+
state: 'success',
48+
context: 'review-workflow',
49+
description: 'No doc changes — admin may merge',
50+
});
51+
3852
const marker = '<!-- ci-admin-merge-bot-comment -->';
39-
const sha = context.payload.pull_request.head.sha.substring(0, 7);
53+
const sha = headSha.substring(0, 7);
4054
const body = `${marker}\n\n✅ **CI build passed** for commit \`${sha}\`\n\nThis PR does not touch documentation content under \`docs/\`, so no multi-stage review is required.\n\n@usace-rmc/docs-admin may merge.`;
4155
const comments = await github.rest.issues.listComments({ owner: context.repo.owner, repo: context.repo.repo, issue_number: prNumber });
4256
const existing = comments.data.find(c => c.user.type === 'Bot' && c.body.includes(marker));

.github/workflows/pr-preview.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
env:
3737
DOCUSAURUS_URL: https://usace-rmc.github.io
3838
DOCUSAURUS_BASE_URL: /RMC-Software-Documentation-Previews/pr-${{ github.event.pull_request.number }}/
39+
DOCUSAURUS_IS_PREVIEW: 'true'
3940
run: npm run build
4041
- uses: peaceiris/actions-gh-pages@v4
4142
with:

docusaurus.config.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,20 @@ export default {
8989
],
9090

9191
plugins: [
92-
// Google Analytics plugin
93-
[
94-
'@docusaurus/plugin-google-gtag',
95-
{
96-
trackingID: 'G-LB2BWWGDTB',
97-
anonymizeIP: true,
98-
},
99-
],
92+
// Google Analytics plugin — production builds only.
93+
// Preview builds set DOCUSAURUS_IS_PREVIEW=true so they don't pollute
94+
// the production GA property with pr-preview page views.
95+
...(process.env.DOCUSAURUS_IS_PREVIEW === 'true'
96+
? []
97+
: [
98+
[
99+
'@docusaurus/plugin-google-gtag',
100+
{
101+
trackingID: 'G-LB2BWWGDTB',
102+
anonymizeIP: true,
103+
},
104+
],
105+
]),
100106

101107
// TailwindCSS as a custom plugin
102108
tailwindPlugin,

0 commit comments

Comments
 (0)