Skip to content

AI-powered virtual executive team — a single coherent executive persona backed by 8 specialist agents (FastAPI + Next.js).

ci: pin every GitHub Action to a commit SHA (#451)

Rufuse4353146f9e2
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index ce977e45..41c12828 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -26,7 +26,7 @@ jobs:
python: ${{ steps.filter.outputs.python }}
ui: ${{ steps.filter.outputs.ui }}
steps:
- - uses: actions/checkout@v7
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
@@ -56,15 +56,15 @@ jobs:
if: needs.changes.outputs.python == 'true'
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v7
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Python
- uses: actions/setup-python@v7
+ uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.11"
- name: Install uv
- uses: astral-sh/setup-uv@v7
+ uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
with:
enable-cache: true
cache-dependency-glob: packages/core/uv.lock
@@ -89,13 +89,13 @@ jobs:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v7
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Python
- uses: actions/setup-python@v7
+ uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.11"
@@ -114,15 +114,15 @@ jobs:
if: needs.changes.outputs.python == 'true'
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v7
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Python
- uses: actions/setup-python@v7
+ uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.11"
- name: Install uv
- uses: astral-sh/setup-uv@v7
+ uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
with:
enable-cache: true
cache-dependency-glob: packages/core/uv.lock
@@ -155,12 +155,12 @@ jobs:
if: needs.changes.outputs.ui == 'true'
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v7
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Node
- uses: actions/setup-node@v7
+ uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "22"
cache: npm
diff --git a/.github/workflows/claude-code-review-fork.yml b/.github/workflows/claude-code-review-fork.yml
index 40f4d05d..be552b7a 100644
--- a/.github/workflows/claude-code-review-fork.yml
+++ b/.github/workflows/claude-code-review-fork.yml
@@ -79,7 +79,7 @@ jobs:
fi
# The base branch, never the PR head (rule 2).
- - uses: actions/checkout@v7
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
if: steps.auth.outputs.ready == 'true'
with:
fetch-depth: 1
@@ -129,7 +129,7 @@ jobs:
- name: Review the PR
if: steps.auth.outputs.ready == 'true'
- uses: anthropics/claude-code-action@v1
+ uses: anthropics/claude-code-action@1d6de8cb0c237e7c15e9e1bdf973826ebae490cc # v1.0.248
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml
index 844c34aa..67c4597e 100644
--- a/.github/workflows/claude-code-review.yml
+++ b/.github/workflows/claude-code-review.yml
@@ -51,14 +51,14 @@ jobs:
echo "::notice::Claude review skipped: set ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN (see the header of .github/workflows/claude-code-review.yml)."
fi
- - uses: actions/checkout@v7
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
if: steps.auth.outputs.ready == 'true'
with:
fetch-depth: 1
- name: Review the PR
if: steps.auth.outputs.ready == 'true'
- uses: anthropics/claude-code-action@v1
+ uses: anthropics/claude-code-action@1d6de8cb0c237e7c15e9e1bdf973826ebae490cc # v1.0.248
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
diff --git a/.github/workflows/release-images.yml b/.github/workflows/release-images.yml
index 412e6bcb..601f855c 100644
--- a/.github/workflows/release-images.yml
+++ b/.github/workflows/release-images.yml
@@ -73,13 +73,13 @@ jobs:
dockerfile: docker/Dockerfile.ui
image: ghcr.io/sentelabsai/openexecutive-ui
steps:
- - uses: actions/checkout@v7
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- - uses: docker/setup-buildx-action@v4
+ - uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- - uses: docker/login-action@v4
+ - uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
@@ -92,7 +92,7 @@ jobs:
# latest=auto), never a branch push. No bare `{{major}}` tag while the
# project is pre-1.0 — a `0` tag would be misleading.
- id: meta
- uses: docker/metadata-action@v6
+ uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
with:
images: ${{ matrix.image }}
tags: |
@@ -110,7 +110,7 @@ jobs:
# provenance=false keeps each tag a plain single-platform image; the
# default attestation manifest shows up as an `unknown/unknown` row on
# the package page.
- - uses: docker/build-push-action@v7
+ - uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: .
file: ${{ matrix.dockerfile }}
@@ -130,7 +130,7 @@ jobs:
permissions:
contents: write
steps:
- - uses: actions/checkout@v7
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml
index 590dd876..caedfa4b 100644
--- a/.github/workflows/release-please.yml
+++ b/.github/workflows/release-please.yml
@@ -64,7 +64,7 @@ jobs:
exit 1
fi
- - uses: googleapis/release-please-action@v5
+ - uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5.0.0
with:
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
config-file: release-please-config.json
diff --git a/packages/core/tests/unit/test_pr_checks.py b/packages/core/tests/unit/test_pr_checks.py
index c30ba4e8..c59e9baa 100644
--- a/packages/core/tests/unit/test_pr_checks.py
+++ b/packages/core/tests/unit/test_pr_checks.py
@@ -300,6 +300,55 @@ def test_tests_present_warns_only() -> None:
assert _level(pr_checks.check_tests_present, changed=changed) == "PASS"
+# --- pinned-actions ----------------------------------------------------------
+
+_SHA = "3d3c42e5aac5ba805825da76410c181273ba90b1"
+
+
+ "line",
+ [
+ " - uses: actions/checkout@v7",
+ " uses: astral-sh/[email protected]",
+ " - uses: 'actions/setup-node@main'",
+ " - uses: actions/checkout@3d3c42e # short sha",
+ ],
+)
+def test_pinned_actions_fails_on_a_tag_or_branch(line: str) -> None:
+ lines = {".github/workflows/ci.yml": [line]}
+ assert _level(pr_checks.check_pinned_actions, changed=set(lines), added_lines=lines) == "FAIL"
+
+
+ "line",
+ [
+ f" - uses: actions/checkout@{_SHA} # v7.0.1",
+ f' uses: "actions/checkout@{_SHA}"',
+ " - uses: ./.github/actions/setup",
+ " - uses: docker://alpine:3.20",
+ " - run: echo uses: actions/checkout@v7",
+ ],
+)
+def test_pinned_actions_passes_shas_and_local_actions(line: str) -> None:
+ lines = {".github/workflows/ci.yml": [line]}
+ assert _level(pr_checks.check_pinned_actions, changed=set(lines), added_lines=lines) == "PASS"
+
+
+def test_pinned_actions_only_reads_workflow_files() -> None:
+ lines = {"docs/ci.md": ["- uses: actions/checkout@v7"]}
+ assert _level(pr_checks.check_pinned_actions, changed=set(lines), added_lines=lines) == "PASS"
+
+
+def test_every_workflow_in_the_repo_pins_its_actions() -> None:
+ root = _SCRIPT.parents[1]
+ lines = {
+ str(p.relative_to(root)): p.read_text().splitlines()
+ for p in (root / ".github").rglob("*.y*ml")
+ }
+ result = pr_checks.check_pinned_actions(Change(changed=set(lines), added_lines=lines))
+ assert result.level == "PASS", result.detail
+
+
# --- git plumbing ------------------------------------------------------------
diff --git a/scripts/pr_checks.py b/scripts/pr_checks.py
index 552ba53c..264c3894 100644
--- a/scripts/pr_checks.py
+++ b/scripts/pr_checks.py
@@ -14,6 +14,8 @@ Checks (see CLAUDE.md -> "Architecture Docs" and "PR Requirements"):
- eval-scenarios FAIL a new agent or a domain-prompt change without an
evals/_scenarios/ change
- tests-present WARN openexecutive/ code changed with no tests/ change
+- pinned-actions FAIL a workflow line added under .github/ uses an action by
+ tag or branch instead of a full commit SHA
A release-please version bump is not a code change: when a file release-please
manages only has the version number rewritten on its marked lines (the release
@@ -94,6 +96,15 @@ CODE_EXT = (".py", ".ts", ".tsx", ".js", ".jsx")
VERSION_MARKER = "x-release-please-version"
RELEASE_PLEASE_FILES = {PKG + "api/main.py", PKG + "api/models.py"}
SEMVER_RE = re.compile(r"\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?")
+# A third-party action named by anything but a full commit SHA: a tag or
+# branch can be moved to new code, which then runs with the workflow's token
+# and secrets. Local actions (./path) and docker:// images are left alone.
+# Dependabot (github-actions) keeps the SHAs and their "# vX.Y.Z" comments
+# current.
+_USES_RE = re.compile(r"^\s*(?:-\s*)?uses:\s*['\"]?(?P<ref>[^\s'\"#]+)")
+_SHA_RE = re.compile(r"@[0-9a-f]{40}$")
+
+
# These files name the stub patterns themselves.
STUB_EXEMPT = {"scripts/pr_checks.py", TESTS + "unit/test_pr_checks.py"}
@@ -259,7 +270,30 @@ def check_tests_present(c: Change) -> Result:
)
-CHECKS = (check_arch_drift, check_no_stubs, check_eval_scenarios, check_tests_present)
+def check_pinned_actions(c: Change) -> Result:
+ hits = []
+ for path, lines in sorted(c.added_lines.items()):
+ if not (path.startswith(".github/") and path.endswith((".yml", ".yaml"))):
+ continue
+ for line in lines:
+ m = _USES_RE.match(line)
+ if not m:
+ continue
+ ref = m.group("ref")
+ if ref.startswith(("./", "docker://")) or _SHA_RE.search(ref):
+ continue
+ hits.append(f"{path}: {ref}")
+ if hits:
+ return Result(
+ "pinned-actions",
+ "FAIL",
+ "actions not pinned to a commit SHA (use owner/repo@<40-hex sha> # vX.Y.Z): "
+ + " | ".join(hits[:5]),
+ )
+ return Result("pinned-actions", "PASS", "added workflow steps pin actions by SHA")
+
+
+CHECKS = (check_arch_drift, check_no_stubs, check_eval_scenarios, check_tests_present, check_pinned_actions)
def run_checks(c: Change) -> list[Result]: