Skip to content

Workflow vendored drift

github-actions[bot] edited this page Nov 7, 2026 · 1 revision

vendored-drift

What it does. Fails when a file vendored from another repository (design tokens, a schema, a shared configuration) is not the bytes its lock pinned, or when what is generated from it is stale. It is read-only, holds no secret and checks nothing out but your repository.

Why it exists. Two repositories that share brand tokens each grew their own copy of the same script. The check is generic: a lock file names the vendored path, the source repository, path and commit, and the SHA-256. It is opt-in; nothing existing changes.

The lock file

One JSON object per vendored file, in your repository:

{
  "vendored": "vendor/brand/tokens.css",
  "sha256": "<64 lowercase hex characters>",
  "source": {"repo": "owner/name", "path": "dist/tokens.css", "commit": "<40 hex characters>"}
}

Exactly those keys; a typo for one is a failure, not an ignored field. Paths are relative and must stay inside the repository after symbolic links are followed. Duplicate keys, a short commit, an uppercase hash, a vendored path that is a directory or a FIFO, and a lock larger than 1 MiB all fail.

What fails the job

  1. A lock that is missing, unreadable or malformed. An empty lock-files fails too: nothing checked is not a pass.
  2. A vendored file whose SHA-256 differs from the pin. The message prints both hashes.
  3. With generator-command: that command with --check appended exits non-zero. It is split like a shell would split it and run without one, from the repository root, with only PATH, HOME, LANG, LC_ALL and TMPDIR in its environment, so a secret in the job cannot reach it and ; or $(...) are plain arguments. Its output is printed prefixed and quoted, so it cannot forge a workflow command.

Every problem is listed before the job fails, not just the first.

A minimal caller

on:
  pull_request:
  push:
    branches: [main]

permissions:
  contents: read

jobs:
  drift:
    uses: ChiefGyk3D/git-your-ship-together/.github/workflows/vendored-drift.yml@<sha> # vX.Y.Z
    permissions:
      contents: read
    with:
      lock-files: vendor/brand/tokens.lock.json
      generator-command: python3 scripts/generate_tokens.py

To re-vendor: copy the new file, update sha256 and source.commit in the lock, regenerate, and commit all of it together. The check then passes only if all four agree.

Running it locally

The script is scripts/check_vendored_drift.py, standard library only. python3 -I scripts/check_vendored_drift.py --lock vendor/brand/tokens.lock.json runs the same checks. The workflow carries a byte-identical copy, because a reusable workflow cannot read files from its own repository; tests/test_vendored_drift.py fails if the copy differs.

Inputs (8), read from vendored-drift.yml:

Input Type Default Meaning
lock-files string empty Newline-separated repository-relative paths of lock files (JSON with vendored, sha256 and source). At least one is required; an empty list fails the job rather than passing with nothing checked.
generator-command string empty Optional command that regenerates what is derived from the vendored file and, with --check appended, exits non-zero when the committed output differs (for example python3 scripts/generate_tokens.py). Run without a shell, from the repository root, with only PATH, HOME, LANG, LC_ALL and TMPDIR in its environment. Empty skips it.
install-command string empty Optional shell run before the check, for what the generator needs (pip install -r requirements.txt). It runs with the job's network allow-list and no secret. Empty skips it.
egress-policy string block harden-runner egress policy - audit logs outbound connections, block allows only allowed-endpoints. Jobs that hold no secret follow egress-policy-secretless instead (EX-0001).
egress-policy-secretless string block harden-runner egress policy for the jobs that hold no stored secret, no OIDC token and no write-scoped or publish-capable token (read-only contents, a SARIF upload at most), and whose output no privileged job consumes - exactly audit or block. Defaults to block since security exception EX-0001 (GitHub-hosted runners in westus2 broke harden-runner block) was closed on 2026-11-02 after harden-runner v2.22.3 passed on westus2; see docs/security/exceptions/. Every job still has the default read-only job token. Set audit to opt out if the defect recurs. Any other job follows egress-policy. Any other value fails the job.
allowed-endpoints string api.github.com:443 github.com:443 harden-runner allow-list for block, space-separated host:port entries. The default is what the checkout needs; wildcards are not supported.
extra-allowed-endpoints string empty Appended to allowed-endpoints, for hosts only the install command or the generator reaches (a package index, for example). Same format.
timeout-minutes number 10 Job timeout.

What it refuses to do

It never writes anything, never holds a credential, and never passes when no lock file was given.

Clone this wiki locally