Skip to content

[WIP] Improve CI workflow examples - #468

Draft
lelia wants to merge 2 commits into
mainfrom
lelia/gha-example-workflows
Draft

lelia wants to merge 2 commits into
mainfrom
lelia/gha-example-workflows

Conversation

@lelia

@lelia lelia commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Tightens the GitHub Actions examples added in 2.14.0 (#460), and moves the CI guide's monorepo workflow into a template of its own. Their structure is unchanged: one PR workflow that owns the required socket-security check, a push workflow for baselines, and an optional ignore-command workflow.

Changes

  • Pinned actions. actions/checkout moves from @v4 to the commit for v7.0.1, the same commit the repository's own CI uses. The CI guide's inline examples get the same treatment: checkout, setup-python and cache were floating on @v5, @v6 and @v4.
  • Least privilege. Each workflow sets permissions: {} and grants per-job permissions, with a comment explaining each one. Every job has a name:. The PR job keeps socket-security, so branch protection doesn't change.
  • Container image. The templates keep socketdev/cli:latest so they stay current with every release, and a comment recommends pinning a release tag and digest for reproducible runs.
  • Ignore commands. The job now runs only when a PR comment contains a @SocketSecurity ignore command, instead of starting a container for every comment. The issue_comment trigger stays, with the reason it's acceptable recorded next to it: the workflow never checks out PR code, and the CLI honors a command only from a commenter with write access.
  • Docs. The CI guide now says that an ignore command updates the Socket comment but not the required check, which keeps the last PR scan's result until the PR workflow runs again.
  • Monorepo example moved. The 171-line per-workspace workflow lived only in docs/ci-cd.md, where no linter checked it. It's now workflows/github-actions-monorepo.yml, an alternative to the PR workflow, and the guide links to it instead of inlining it. It gained named jobs and a concurrency group; its aggregate socket-security gate already ran with if: always().
  • Staying current. Dependabot updates .github/workflows but not workflows/ or the docs, which is how the templates fell four majors behind. A new test fails when an example uses an unpinned action or a different commit than CI. It also checks that only the PR workflow and the monorepo alternative report socket-security, and that the monorepo gate always reports. When Dependabot bumps an action in CI, the test points to the examples that need the same change.

Why still three files

Triggers are per file in GitHub Actions, and GitHub counts a skipped job as passing. So the required check needs a workflow whose only trigger is pull_request. The push and ignore-command jobs could share a second file, but every PR would then show a skipped ignore-command check, and the issue_comment trigger would move into the baseline workflow.

What makes the split feel heavy is the repeated container, checkout and CLI boilerplate. Removing that needs a shared step that Socket hosts. A local composite action or reusable workflow would only add a fourth file for users to copy. The natural home is a Python CLI mode in SocketDev/action, which already has firewall, patch and CLI modes, or a reusable workflow in this repository. Either way, each template becomes a trigger plus one pinned step, but it means supporting a new interface, so it's left as a follow-up.

Verification

  • zizmor 1.33.1, default and pedantic personas: no findings across all four templates. Before, the default persona reported 7 high findings and pedantic 15 in total. Four findings remain suppressed inline, each with its reason: latest in the three templates, and the issue_comment trigger.
  • actionlint: clean.
  • 1,175 tests pass, including 15 new template tests; the pin checks fail against the templates on main. ruff check and uv lock --locked pass.

Release

This ships separately from 2.14.0. The branch bumps to 2.14.1 with its own changelog section, so merge it after 2.14.0 is published.

Public Changelog

The GitHub Actions examples pin their actions to commits, start with no token permissions, and pass zizmor. The ignore-command example runs only for ignore commands. The CI guide explains re-running the required check after an ignore command.


Fixes: CE-524

Pin actions/checkout to a commit, drop default token permissions, explain each job permission and name every job while keeping the socket-security check name. The ignore-command example now runs only for ignore commands. A test keeps the examples' action pins in step with the commits the repository's CI uses.
@lelia
lelia temporarily deployed to socket-firewall November 24, 2026 05:07 — with GitHub Actions Inactive
@lelia lelia changed the title Pin, scope and audit the GitHub Actions examples [WIP] Improve CI workflow examples Nov 24, 2026
The 171-line per-workspace workflow lived only in docs/ci-cd.md, where no linter checked it. It's now a template alongside the others, covered by actionlint, zizmor and the pin test, and the guide links to it.
@lelia
lelia deployed to socket-firewall November 24, 2026 05:13 — with GitHub Actions Active

This branch was successfully deployed

1 active deployment
socket-firewall — 6f2090ec Deployed Nov 24, 2026 by lelia via python-sfw-smoke-enterprise #703
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