Skip to content

refactor(workflows): move pages, release and label-sync run scripts into scripts/ - #544

Merged
DevSecNinja merged 4 commits into
devsecninja-lint-inline-scripts-lint-ymlfrom
devsecninja-lint-inline-scripts-release-workflows
Nov 17, 2026
Merged

DevSecNinja merged 4 commits into
devsecninja-lint-inline-scripts-lint-ymlfrom
devsecninja-lint-inline-scripts-release-workflows

Conversation

@DevSecNinja

Copy link
Copy Markdown
Owner

Description

Layer 2b of #537, stacked on #543. The multi-line run: blocks of the reusable pages, release, release-please and label-sync workflows move into scripts, following the pattern #543 set up for lint.yml. The inline-script checker now reports nothing for those four files (8 findings before; 0 to move, 1 documented opt-out). Behaviour doesn't change: the script bodies are the old run: blocks, reindented by shfmt. I checked each one against its original block after shfmt; the only differences are the lint fixes listed below.

Changes

  • scripts/pages/: validate-inputs.sh, detect-cloudflare.sh, update-sitemap-lastmod.sh, register-cloudflare-domain.sh and delete-preview-deployments.sh, one per former run: block of pages.yml. Every job that runs one starts with Checkout pages scripts (sparse checkout of scripts/pages/ at job.workflow_sha) and Move pages scripts out of the workspace (mv to $RUNNER_TEMP). The privileged deploy job only fetches them when update-sitemap-lastmod is set, so the GitHub Pages deploy does no extra checkout otherwise. ${{ }} values still reach the scripts only through env:.
  • scripts/label-sync/resolve-config-files.sh: the config-file resolver of label-sync.yml, with the same fetch and move steps before the code checkout.
  • release.yml: gh release create is now a single line. No script needed.
  • release-please.yml: the Validate GitHub App credentials step stays inline with # lint: allow-inline-script and a comment giving the reason. It reads the App private key, so tests/app-key-confinement.py pins its run: by SHA-256, checks how it reads the key, and allows no step before it except harden-runner. Moving it to a fetched script would need a checkout step before it and would take the key-reading code out of reach of that test. Its run: is unchanged, so the pinned hash still matches. The App key stays confined to the token step.
  • Lint fixes in the moved code, all behaviour-neutral under config-sync/files/.shellcheckrc: ${REPOSITORY_NAME} braces, a no-op *) ;; default case, and two justified shellcheck disable comments (SC2153 for an env input, SC2312 for api_errors, which never fails).
  • .github/actionlint.yaml: the job.workflow_* ignore from refactor(lint): move lint.yml run scripts into scripts/lint #543 now also covers pages.yml and label-sync.yml.
  • Tests:
    • tests/pages-custom-domain-contract.sh runs validate-inputs.sh and register-cloudflare-domain.sh directly instead of extracting them from the workflow. All existing cases are unchanged.
    • New tests/pages-scripts.sh covers the pages scripts that had no tests: Cloudflare detection (disabled, missing secrets, invalid project name, production/acceptance targets, production-on-release), the sitemap lastmod update, and preview cleanup with a curl stand-in (branch filter, failed delete only warns, list and parse failures).
    • New tests/label-sync-scripts.sh covers merging, skipping and the no-files error.
    • New tests/workflow-script-fetch.py checks every reusable-workflow job that runs a $RUNNER_TEMP script: it must start with a SHA-pinned checkout of job.workflow_repository at job.workflow_sha without persisted credentials, followed by the mv. The sparse checkout must include the script, the script must exist, and a conditional fetch must share its condition with every step that runs a script. It covers lint.yml as well.
    • tests/lint-inline-scripts.py runs the checker in blocking mode on the four files as well as lint.yml.
  • docs/architecture.md: a Workflow scripts paragraph on where scripts live, how jobs fetch them, and the App-key preflight exception. scripts/ and tests/ are added to the layout tree.

Known edge (same as #543): if fetching the scripts fails, the job fails at that step instead of at the script.

Refs #537

Checklist

  • Linting passes locally (mise exec -- lefthook run pre-commit)
    • No lefthook config exists at the repository root, so I ran the linters directly: actionlint (exit 0), shellcheck --rcfile config-sync/files/.shellcheckrc and shfmt -d on all new scripts (exit 0), yamlfmt -lint and yamllint with the config-sync/files configs on the changed workflows (exit 0), dprint check on docs/architecture.md (exit 0), zizmor --offline on the four workflows (no findings).
    • The new and changed tests are clean under default shellcheck. Under the repo .shellcheckrc they report only the opt-in SC2310/SC2312 info checks, the same ones the existing tests already report.
    • uv run --script scripts/lint-inline-scripts.py --blocking on the four workflows: 0 to move, 1 opted out.
    • uv run --script tests/app-key-confinement.py: passed (4 token steps, 3 emptiness checks, 30 fixture cases).
    • uv run --script tests/lint-inline-scripts.py: passed (5 files clean in blocking mode).
    • uv run --script tests/workflow-script-fetch.py: passed (label-sync 1, lint 32, pages 5 script steps). A mutation check confirmed it catches a missing condition, a wrong ref, a missing move step and a script left out of the sparse checkout.
    • python3 tests/workflow-job-conditions.py: passed (18 pages.yml scenarios).
    • Bash tests on Debian/WSL: pages-custom-domain-contract.sh, pages-scripts.sh, label-sync-scripts.sh, release-please-auth-contract.sh, automation-app-contract.sh, lint-job-modes-contract.sh, lint-scripts.sh, open-pr-*.sh, copilot-model-policy-contract.sh and config-sync-ai-toolkit-instructions.sh passed.
    • Not run locally: the renovate, config-sync-lint-excludes, config-sync-renovate-stub and gitleaks tests, which need pyjson5, dprint or gitleaks in WSL. They cover areas this PR doesn't touch, and CI runs them.
  • Commit messages follow Conventional Commits
  • Documentation updated (if applicable)

@DevSecNinja
DevSecNinja requested a balanced review from Copilot November 16, 2026 16:43
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 50 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 43c23775-41e8-48e6-a8a3-6b298c860fba
Commits

Reviewing files that changed from the base of the PR and between bc881e6 and a49cb9e.

Files selected for processing: 18

  • .github/actionlint.yaml
  • .github/workflows/label-sync.yml
  • .github/workflows/pages.yml
  • .github/workflows/release-please.yml
  • .github/workflows/release.yml
  • .mise.toml
  • docs/architecture.md
  • scripts/label-sync/resolve-config-files.sh
  • scripts/pages/delete-preview-deployments.sh
  • scripts/pages/detect-cloudflare.sh
  • scripts/pages/register-cloudflare-domain.sh
  • scripts/pages/update-sitemap-lastmod.sh
  • scripts/pages/validate-inputs.sh
  • tests/label-sync-scripts.sh
  • tests/lint-inline-scripts.py
  • tests/pages-custom-domain-contract.sh
  • tests/pages-scripts.sh
  • tests/workflow-script-fetch.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified, though runtime tests and linters were not run during the static review.

No open issues 🎉

What changed in this PR

Continues #537’s inline-script cleanup, extending the pattern from #543 to the shared Pages, label-sync, and release workflows. The refactor moves shell logic into directly testable scripts while preserving existing behavior.

Changes:

  • Extracts Pages and label-sync scripts, fetched at the reusable workflow’s SHA and moved outside the caller’s workspace.
  • Simplifies the release command and documents the unchanged release-please credential preflight’s inline exception.
  • Adds script tests and checkout-contract checks, expands inline-script enforcement, and updates architecture documentation.

Runtime tests and linters were not run during this static review.

File Description
tests/​workflow-script-fetch.py Checks script checkout, pinning, paths, and conditions.
tests/​pages-scripts.sh Covers Cloudflare detection, sitemap updates, and preview cleanup.
tests/​pages-custom-domain-contract.sh Tests extracted validation and registration scripts directly.
tests/​lint-inline-scripts.py Adds four workflows to blocking checks.
tests/​label-sync-scripts.sh Covers config selection and missing-file handling.
scripts/​pages/​validate-inputs.sh Extracts Pages input validation.
scripts/​pages/​update-sitemap-lastmod.sh Extracts sitemap date updates.
scripts/​pages/​register-cloudflare-domain.sh Extracts custom-domain registration and DNS handling.
scripts/​pages/​detect-cloudflare.sh Extracts Cloudflare deployment-target selection.
scripts/​pages/​delete-preview-deployments.sh Extracts branch-specific preview cleanup.
scripts/​label-sync/​resolve-config-files.sh Extracts label config-file resolution.
docs/​architecture.md Documents script layout, fetching, and the credential exception.
.mise.toml Registers the new tests.
.github/​workflows/​release.yml Converts release creation to one command line.
.github/​workflows/​release-please.yml Documents and marks the unchanged inline preflight exception.
.github/​workflows/​pages.yml Fetches and invokes the extracted Pages scripts.
.github/​workflows/​label-sync.yml Fetches and invokes the label config resolver.
.github/​actionlint.yaml Extends workflow-context compatibility ignores.

Review effort: Balanced

@DevSecNinja
DevSecNinja added this pull request to stack #553 November 16, 2026 20:10
@DevSecNinja
DevSecNinja force-pushed the devsecninja-lint-inline-scripts-release-workflows branch from f1821d8 to 0ff5646 Compare November 16, 2026 20:52
DevSecNinja added a commit that referenced this pull request Nov 16, 2026
Layer 2c of #537. The multi-line run: blocks of the config-sync,
apm-sync, apm-materialize, vendored-file-sync and autofix workflows move
into scripts/<workflow>/, fetched at job.workflow_sha like #543 and #544
did. The App-key preflights of config-sync and apm-sync stay inline with
a lint opt-out, since tests/app-key-confinement.py pins them, and
tests/workflow-script-fetch.py now lets them (and harden-runner) run
before the fetch steps.

Refs #537

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
DevSecNinja and others added 4 commits November 17, 2026 11:58
release.yml calls gh release create on one line. The Release Please
credential preflight reads the App key, so it stays inline with a
documented opt-out: tests/app-key-confinement.py pins its run: by
SHA-256 and allows no earlier step, which a script fetch would need.

Refs #537

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…l-sync

The job fetches the script at job.workflow_sha and moves it to
$RUNNER_TEMP before the code checkout, as lint.yml does. Adds
tests/label-sync-scripts.sh.

Refs #537

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The five multi-line run blocks become scripts that each job fetches at
job.workflow_sha. The deploy job only fetches them when
update-sitemap-lastmod is set. pages-custom-domain-contract.sh now runs
the scripts directly, and tests/pages-scripts.sh covers Cloudflare
detection, the sitemap update and preview cleanup.

Refs #537

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
tests/workflow-script-fetch.py checks every reusable workflow job that
runs a script from $RUNNER_TEMP. The inline-script test now runs
pages, release, release-please and label-sync in blocking mode, and
docs/architecture.md describes where workflow scripts live.

Refs #537

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@DevSecNinja
DevSecNinja force-pushed the devsecninja-lint-inline-scripts-release-workflows branch 2 times, most recently from 2f5e255 to a49cb9e Compare November 17, 2026 11:03
DevSecNinja added a commit that referenced this pull request Nov 17, 2026
Layer 2c of #537. The multi-line run: blocks of the config-sync,
apm-sync, apm-materialize, vendored-file-sync and autofix workflows move
into scripts/<workflow>/, fetched at job.workflow_sha like #543 and #544
did. The App-key preflights of config-sync and apm-sync stay inline with
a lint opt-out, since tests/app-key-confinement.py pins them, and
tests/workflow-script-fetch.py now lets them (and harden-runner) run
before the fetch steps.

Refs #537

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@DevSecNinja
DevSecNinja merged commit 6c41b6e into main Nov 17, 2026
38 checks passed
@DevSecNinja
DevSecNinja deleted the devsecninja-lint-inline-scripts-release-workflows branch November 17, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants