How I Built a Self-Refreshing Marketing Dashboard with GitHub Actions and a Parity Gate

By Rohan Babbar6 min read
How I Built a Self-Refreshing Marketing Dashboard with GitHub Actions and a Parity Gate

Most marketing dashboards don't fail with an error screen. They fail quietly: a scheduled pull stops updating, a metric calculation drifts after a code edit, or a serverless deploy drops a data folder and renders zeros with no warning.

A blank with a warning beats a plausible wrong number. When I built a multi-brand marketing intelligence application in Next.js and TypeScript (joining paid media, GA4, Search Console and CRM revenue), I wired the daily refresh through GitHub Actions with two hard gates: a freshness guard and a regression parity gate. If either fails, nothing commits and nothing deploys.

Below is the exact architecture, the guardrails that keep raw PII off disk, and the real production bugs that broke early runs before the pipeline stabilised.

Why scheduled marketing dashboards silently rot

When a CMO or founder opens a morning dashboard, four silent failure modes destroy trust faster than a missing chart:

  • Silent date regression. An upstream API fails or returns a partial export, and an unguarded sync overwrites yesterday's good data with incomplete rows.
  • Metric drift across rewrites. Porting reporting logic from an analytics script (for example, Python) into a web app (TypeScript) introduces rounding, tax or date-capping differences nobody notices for weeks.
  • Raw PII creeping into Git. Pulling full source exports straight into a repository risks committing customer rows or bloating deploys with tens of megabytes of unused JSON.
  • Green CI ticks that deploy broken routes. Static and serverless bundlers routinely skip files referenced via dynamic paths, leaving a green build that returns empty data in production.

The architecture: daily cron with two hard gates

The pipeline runs every morning on a GitHub Actions schedule (plus manual dispatch for restatements):

  1. Isolated checkout in RUNNER_TEMP. Raw upstream reporting snapshots are cloned into the runner's temporary directory, never inside the application repo.
  2. Manifest check + lean snapshot trim. A script checks that the upstream manifest is complete, aborts on partial exports, and writes only whitelisted aggregate/daily fields (cutting payload size from ~28 MB of raw files down to ~5 MB of aggregate JSON — order-level PII never touches the repo).
  3. Freshness guard. Before staging a commit, the script compares the new snapshot against the committed baseline. It commits only if the maximum data date advanced, or if a same-date restatement actually changed bytes. Regressions or identical reruns exit cleanly with zero commits.
  4. Hard regression parity gate. A TypeScript test suite compares the web app's computed totals against the upstream ground-truth numbers byte-for-byte. Any mismatch fails the workflow before git commit, blocking the Vercel production deploy.
  5. Scoped credential hygiene. Instead of rewriting global git config (which can break push authentication), the workflow binds the read-only data token to the upstream repository URL inside a throwaway GIT_CONFIG_GLOBAL file so credentials never leak into build logs.
name: Refresh Marketing Snapshot
on:
  schedule:
    - cron: "30 2 * * *" # 08:00 IST daily
  workflow_dispatch:

jobs:
  refresh:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v5
      - uses: actions/setup-python@v6
        with:
          python-version: "3.12"
      - uses: actions/setup-node@v4
        with:
          node-version: "22"

      - name: Pull upstream snapshot into RUNNER_TEMP and trim
        env:
          DATA_REPO_PAT: ${{ secrets.DATA_REPO_PAT }}
        run: |
          TMP_GITCFG="$RUNNER_TEMP/gitconfig"
          git config --file "$TMP_GITCFG" \
            "url.https://x-access-token:${DATA_REPO_PAT}@github.com/org/analytics-source.git.insteadOf" \
            "https://github.com/org/analytics-source.git"
          GIT_CONFIG_GLOBAL="$TMP_GITCFG" python scripts/refresh_snapshot.py --workdir "$RUNNER_TEMP/src"

      - name: Run regression parity gate
        run: npm run test:parity -- --hard-gate-only

      - name: Commit only if data advanced or restated
        run: |
          if git diff --quiet -- data/snapshot/; then
            echo "No freshness advance or restatement — skipping commit."
            exit 0
          fi
          git config user.name "snapshot-bot"
          git config user.email "bot@example.com"
          git add data/snapshot/
          git commit -m "chore: refresh verified marketing snapshot"
          git push

Four real production bugs that broke the pipeline (and the fixes)

Every guardrail in the workflow above exists because the simpler version failed in production first:

Failure hit in production Root cause Fix
First CI run failed with 403 on clone Fine-grained PAT was scoped without Contents: Read on the data repo, and a global url.insteadOf rewrite broke pushing back to the app repo Granted read-only Contents scope and bound insteadOf to the exact upstream repo URL inside a throwaway GIT_CONFIG_GLOBAL
Scheduled parity gate failed with TS5112 / TS5023 / TS5108 Newer tsc rejected CLI file + flag arguments when tsconfig.json existed; --ignoreConfig failed on older tsc; --moduleResolution node was removed in tsc 7 Generated a throwaway tsconfig.parity.json and ran tsc --project, verified for identical output across TypeScript 5.9 and 7.0
Serverless API route returned 0 issues on Vercel despite passing locally Next.js's output file tracer misses data files when paths are built dynamically from brand variables Added explicit outputFileTracingIncludes in next.config.ts for the snapshot directory
Manual "Refresh" button created cross-section skew One cached API tag was missing from the revalidation list, so paid ads refreshed while overview totals stayed stale Audited every cache tag in the refresh handler and added a visible "Data through" badge (which deliberately trails today because Search Console lags)

Metric rules enforced inside the parity gate

A parity gate is only as trustworthy as the accounting rules locked inside it:

  • Tax normalisation on spend. Ad platforms that report pre-tax spend are normalised consistently on read without double-applying tax to already inclusive sources.
  • Common as-of date capping. Because offline bookings and B2B deals lag ad clicks by several days, spend and revenue are capped to the same verified date before calculating ROAS.
  • Non-additive GA4 rules. Total Users cannot be summed across days; daily rollups feature Sessions and an explicit key-event allowlist rather than generic conversion totals.
  • Weighted Search Console position. Average position across date ranges is computed as Σ(position × impressions) ÷ Σ(impressions), never a simple mean of daily averages.

For the revenue-verification side of this architecture, see how to calculate real ROAS from CRM revenue. For lighter reporting built directly into Google Sheets, see connecting Google Search Console to Claude.

How this pattern applies across industries

Industry Upstream data joined What the parity gate protects
E-commerce Ad spend + Shopify net orders after cancellations/refunds Stops gross checkout values from inflating ROAS
B2B LinkedIn/Google Ads spend + CRM qualified pipeline stages Prevents stage-change drops from hiding stalled deals
Education Paid/organic leads + confirmed enrolments Keeps inquiry spikes separate from actual fee-paid seats
Services & Hospitality Multi-channel spend + PMS/CRM confirmed bookings Caps booking lag and strips complimentary or cancelled reservations

More of the production systems I've built — including lead pipelines, multi-entity CRM, and human-gated AI qualification — are documented on my systems page.

FAQ

Why use GitHub Actions instead of a paid BI connector?

GitHub Actions gives you versioned snapshots, deterministic pre-deploy tests, zero per-row connector fees, and full control over data-quality rules. If an upstream schema changes or an export is incomplete, CI stops the deploy before leadership sees broken numbers.

Why keep raw exports in RUNNER_TEMP instead of the repository?

Cloning raw source data into RUNNER_TEMP guarantees customer-level PII and oversized historical files never enter Git history. Only whitelisted aggregate and daily metrics are copied into the committed snapshot.

What is a regression parity gate in marketing analytics?

It is an automated check that compares the numbers calculated by your dashboard code against a verified reference baseline before any update ships. If a refactor or upstream data change shifts a total unexpectedly, the check fails and blocks deployment.

Why did my Next.js API route return empty data on Vercel after working locally?

Next.js traces imported files at build time, but skips files read with dynamic fs.readFileSync paths built from variables. Adding the data directory to outputFileTracingIncludes in next.config forces Vercel to bundle the snapshot files with the route.


If your leadership team doesn't trust the numbers in its marketing dashboards — or you're hiring someone who owns both performance marketing and the data layer behind it — see my consulting work, message me on LinkedIn, or email rohan.sgtb@gmail.com.

github actionsmarketing analyticsnext.jstypescriptattribution
ShareLinkedInX
Rohan Babbar
Rohan Babbar

Digital Marketing Manager — paid media, SEO and marketing systems. Connect on LinkedIn · rohan.sgtb@gmail.com