Skip to content

Run the workflows against this repo on merge and PR - #12

Merged
kaiomagalhaes merged 2 commits into
mainfrom
ci/self-scan
Aug 9, 2026
Merged

kaiomagalhaes merged 2 commits into
mainfrom
ci/self-scan

Conversation

@kaiomagalhaes

Copy link
Copy Markdown
Member

This repository ships reusable workflows and had no CI of its own. Nothing was exercised until after it had already landed in every consuming repo — and since they all reference @main unpinned, production was the test environment.

Two bugs shipped exactly that way: a documented allowed_outdated_libraries input that never existed in the workflow, and gate steps whose jq check ignored --audit-level entirely.

What runs

secret-scan — calls security.yml on this repo. Dogfooding: if the scanner breaks, it breaks here first.

  • notify_webhook: false — there is no SECURITY_WEBHOOK_URL secret in this repo, and validate-inputs correctly fails when notifications are on without one.
  • scan_filesystem: true — safe, because those findings are advisory and cannot block.

lint-workflows — runs actionlint, which validates workflow syntax, expressions and contexts, and runs shellcheck over the inline run: scripts. That last part matters most here: the real logic in this repo lives in shell inside YAML, which nothing else checks.

It installs from a pinned release with checksum verification rather than pulling a third-party action — consistent with how TruffleHog is installed in security.yml, and with this repo's own rule about not trusting mutable refs inside a security pipeline.

Triggers

push to main and pull_request. You asked for merges to main; I added PR runs too, because catching a break before it merges is the actual goal — consumers pick up @main the instant it lands, so a post-merge signal is already too late. Happy to drop the PR trigger if you'd rather keep it to main only.

What is deliberately not run

node-security-dependency-scan.yml is not called. It runs npm ci, and this repository has no package.json, so it would fail for reasons that say nothing about whether the workflow is correct. Worth revisiting if a fixture project is ever added here.

One existing issue fixed

actionlint found SC2129 in node-security-dependency-scan.yml — individual redirects to $GITHUB_STEP_SUMMARY in the OWASP report step. Converted to a single grouped redirect so the new lint job starts green rather than red on arrival.

Verification

I ran actionlint locally rather than assuming it would pass:

actionlint 1.7.12 — exit 0, no issues across all four workflow files

And confirmed the install step's checksum grep against the real actionlint release:

8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8  actionlint_1.7.12_linux_amd64.tar.gz
✅ matches exactly one line

Note this PR is the first real test of itself — the pull_request trigger means both jobs should run on this very PR.

Kept separate from #11 (README rewrite) so that one stays docs-only.

kaiomagalhaes and others added 2 commits August 9, 2026 13:19
This repository ships reusable workflows and had no CI of its own, so
nothing was exercised until after it had already landed in every
consuming repo - which, since they all reference @main unpinned, meant
production was the test environment. Two bugs shipped that way: a
documented `allowed_outdated_libraries` input that never existed, and
gate steps whose jq check ignored --audit-level entirely.

Adds self-scan.yml with two jobs:

- secret-scan: calls security.yml on this repo. notify_webhook is off
  because there is no SECURITY_WEBHOOK_URL secret here and
  validate-inputs correctly fails when notifications are on without one.
  scan_filesystem is on, which is safe since those findings are advisory.

- lint-workflows: runs actionlint, which validates workflow syntax,
  expressions and contexts, and runs shellcheck over the inline `run:`
  scripts - where the real logic in this repo lives. Installed from a
  pinned release with checksum verification rather than via a
  third-party action, matching how TruffleHog is installed.

Runs on pull_request as well as pushes to main. Catching a problem
before the merge is the point, given consumers pick up @main instantly.

node-security-dependency-scan.yml is deliberately not called: it runs
`npm ci` and this repository has no package.json, so it would fail for
reasons unrelated to whether the workflow is correct.

Also fixes the one issue actionlint found in existing code - SC2129,
individual redirects to $GITHUB_STEP_SUMMARY in the OWASP report step,
now a single grouped redirect - so the new job starts green.

Verified: actionlint 1.7.12 reports no issues across all four workflow
files, and the checksum grep the install step uses was run against the
real actionlint release, matching exactly one line.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Was push-to-main plus pull_request. Now `branches: ["**"]`, matching how
consuming repos call these workflows, so every push exercises them.

Dropped the pull_request trigger: with pushes on all branches it only
duplicated runs for same-repo branches. The tradeoff is that PRs opened
from forks no longer trigger a run, since fork pushes do not fire in the
base repo. Worth adding back if this repo ever takes fork contributions.

Documented why the jobs use local `./.github/...` references rather than
`@main`: GitHub resolves a local reusable-workflow reference against the
same commit as the caller, so a branch push tests that branch's copy.
Referencing `@main` would silently test the already-merged version and
defeat the purpose.

Verified rather than assumed. Pushed a scratch branch carrying a marker
echo that existed only on that branch, and the marker executed inside
the secret-scan job - confirming the called workflow comes from the
branch commit, not from main. Scratch branch removed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@kaiomagalhaes

Copy link
Copy Markdown
Member Author

Updated per feedback: runs on every branch push, not just main.

on:
  push:
    branches: ["**"]

This matches how consuming repos call these workflows. I dropped the pull_request trigger — with pushes on all branches it only duplicated runs for same-repo branches. The tradeoff: PRs opened from forks no longer trigger a run, since fork pushes don't fire in the base repo. Worth adding back if this repo ever takes fork contributions.

"Can we test the current version always?" — yes, and it already does

This hinges on the jobs referencing the workflows by local path (./.github/workflows/security.yml) rather than @main. GitHub resolves a local reusable-workflow reference against the same commit as the caller, so a push to any branch exercises that branch's copy. Referencing @main would silently test the already-merged version and defeat the entire point.

I verified this rather than trusting the docs. Pushed a scratch branch containing a marker that existed only on that branch:

secret-scan / TruffleHog Secret Scan
  echo "MARKER_FROM_BRANCH_NOT_MAIN_9f3a2c"
  MARKER_FROM_BRANCH_NOT_MAIN_9f3a2c

The marker executed inside the secret-scan job — proving the called workflow came from the branch commit, not from main. Scratch branch has been deleted, and security.yml on this branch is byte-identical to main (the marker was never carried over).

So the practical effect: push a change to security.yml on a branch, and that branch's run tests the modified version before it can reach any consumer.

actionlint still passes clean across all four workflow files.

@kaiomagalhaes
kaiomagalhaes merged commit b28f1c1 into main Aug 9, 2026
4 checks passed
@kaiomagalhaes
kaiomagalhaes deleted the ci/self-scan branch August 9, 2026 16:45
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.

1 participant