diff --git a/.env.example b/.env.example new file mode 100644 index 000000000..ebab11a84 --- /dev/null +++ b/.env.example @@ -0,0 +1,6 @@ +# Google Analytics Tracking ID +# For local development, copy this file to `.env` and set your real tracking ID. +# For GitHub Actions, set `GA_TRACKING_ID` in repository variables (not secrets). +# Reference: Settings > Secrets and variables > Actions > Variables +# If deploying on Netlify, configure `GA_TRACKING_ID` in Netlify environment variables separately. +GA_TRACKING_ID=G-XXXXXXXXXX diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..c544d70df --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,30 @@ +name: Build Docusaurus + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.14.0' + cache: 'yarn' + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Build Docusaurus + run: yarn build + env: + GA_TRACKING_ID: ${{ vars.GA_TRACKING_ID }} diff --git a/.gitignore b/.gitignore index 2fa3effc9..56dfa6e13 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ # Misc .DS_Store +.env .env.local .env.development.local .env.test.local diff --git a/docusaurus.config.js b/docusaurus.config.js index 3c5a39bd7..57624d200 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -43,10 +43,12 @@ const config = { showLastUpdateAuthor: true, showLastUpdateTime: true, }, - gtag: { - trackingID: "G-854W8PEZ1Z", - anonymizeIP: true, - }, + ...(process.env.GA_TRACKING_ID && { + gtag: { + trackingID: process.env.GA_TRACKING_ID, + anonymizeIP: true, + }, + }), blog: { showReadingTime: true, feedOptions: {