← Back to Pull requests

ci: repack dist/ on dependabot branches without exposing a write token #390

Closed
unknown closed this pull request without merging on Oct 09, 2026 17:58 UTC
View on GitHub
unknown unknown commented on Oct 08, 2026 15:24 UTC
Author

Description

Every dependabot PR that bumps an ncc-bundled dependency permanently fails the "Verify committed dist/ matches source" gate, because dependabot never runs npm run pack (see #167). This PR rebuilds dist/ on same-repo dependabot branches and pushes the result back — reworked per review so the write credential never coexists with dependency code:

  • repack-dist (no secrets): checks out the PR head SHA with persist-credentials: false, installs with npm ci --ignore-scripts, builds, packs, and uploads dist/ as an artifact only when it drifted. The bumped dependency code that runs here can read nothing.

  • push-repacked-dist (no npm): mints a short-lived App token (actions/create-github-app-token), refuses to proceed if the branch moved since the rebuild, downloads the artifact, refuses any change outside dist/, and pushes with --force-with-lease. No contents: write is requested on GITHUB_TOKEN.
  • Gated on github.event.pull_request.user.login == 'dependabot[bot]' and a same-repo head.

    Maintainer setup required: create (or reuse) a GitHub App with contents: write, install it on this repository, and store its id/key as the Dependabot secrets REPACK_APP_ID / REPACK_APP_PRIVATE_KEY (dependabot-triggered runs only see Dependabot secrets). Pushing with the App token is also what re-triggers build-test on the new commit.

    Follow-ups noted from review, not in this PR: a tag ruleset or an on-main check in release.yml to constrain what any compromised credential could ship. If the maintainers prefer the simpler route (keep the gate, hand-run npm run pack), this PR can be dropped — #411 carries the js-yaml move independently.

    The js-yaml move was split out to #411 per review.

    Fixes #171

    Testing

  • npm ci --ignore-scripts && npm run build && npm run pack on a clean checkout — reproduces the committed dist/ byte-for-byte (git status --porcelain dist/ empty), so the no-scripts rebuild is sound

  • test.yml parses cleanly (js-yaml load; jobs: build-test, repack-dist, push-repacked-dist)

  • Action pins verified against upstream releases: checkout v7.0.1 / setup-node v7.0.0 / upload-artifact v7.0.1 (repo's existing pins), download-artifact v8.0.2, create-github-app-token v3.2.0
  • Checklist

  • I ran npm run all to lint and build my code — not applicable, workflow-only

  • I ran npm run pack and committed dist/ — not applicable, dist/ unchanged

  • Commits are signed off (DCO)

  • Note any new dependencies these changes bring in — two new pinned actions: actions/download-artifact, actions/create-github-app-token

  • I have performed a self-review of my own code

  • I have commented my code, particularly in hard-to-understand areas

  • I have made corresponding changes to the documentation — none needed

  • My changes generates no new warnings (please describe new warnings if unavoidable)
  • Diff: 368 lines (+276 / -92) across 4 files Reviewer: jeefy Review duration: 1594m
    All Vouch review confidence checks passed
    Residual risk 0.26 = Change Risk (0.66) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.66 · 368 lines diff across 4 files
    0.66
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.354
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.066
    Real PR Conversation Timeline
    1 comments
    "Review active on #390"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 65.9% (HIGH) · Higher = larger blast radius
    65.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 26% · Safe to merge
    26%