Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

ci(images): make the dispatch path deploy like a push (#122452)

Georges-Antoine Assie5711828cd43
diff --git a/.github/workflows/container-images-cd.yml b/.github/workflows/container-images-cd.yml
index dd2a7e83b80f..e9d86a829d5c 100644
--- a/.github/workflows/container-images-cd.yml
+++ b/.github/workflows/container-images-cd.yml
@@ -114,6 +114,12 @@ jobs:
with:
fetch-depth: 2
+ - name: Resolve commit timestamp
+ id: commit-time
+ env:
+ HEAD_COMMIT_TIMESTAMP: ${{ github.event.head_commit.timestamp }}
+ run: echo "timestamp=${HEAD_COMMIT_TIMESTAMP:-$(TZ=UTC git show -s --date=format-local:%Y-%m-%dT%H:%M:%SZ --format=%cd HEAD)}" >> "$GITHUB_OUTPUT"
+
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
@@ -362,7 +368,7 @@ jobs:
- name: Verify image boots (web + temporal + celery)
if: github.event_name == 'push'
env:
- IMAGE: ghcr.io/posthog/posthog:${{ github.sha }}
+ IMAGE: ${{ steps.docker-meta.outputs.ecr-registry }}/${{ env.ECR_REPOSITORY }}@${{ steps.image.outputs.digest }}
run: |
set -euo pipefail
docker pull "$IMAGE"
@@ -738,7 +744,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
- name: Trigger Ingestion Cloud deployment
@@ -759,7 +765,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ toJson(steps.labels.outputs.labels) }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
- name: Trigger Batch Exports Temporal Worker Cloud deployment
@@ -780,7 +786,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
- name: Trigger Max AI Temporal worker cloud deployment
@@ -801,7 +807,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
- name: Trigger Tasks Agent Temporal worker cloud deployment
@@ -822,7 +828,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
- name: Install uv for dependency analysis
@@ -897,7 +903,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
- name: Trigger Video Export Temporal Worker Cloud deployment
@@ -918,7 +924,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
- name: Trigger Self-Driving Temporal Worker Cloud deployment
@@ -939,7 +945,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
- name: Trigger Session Replay Temporal Worker Cloud deployment
@@ -960,7 +966,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
- name: Trigger Replay Vision Temporal Worker Cloud deployment
@@ -981,7 +987,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
- name: Trigger Web Analytics Temporal Worker Cloud deployment
@@ -1002,7 +1008,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
- name: Trigger Experiments Recalculation Temporal Worker Cloud deployment
@@ -1023,7 +1029,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
- name: Trigger Error Tracking Temporal Worker Cloud deployment
@@ -1044,7 +1050,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
- name: Trigger Weekly Digest Temporal Worker Cloud deployment
@@ -1065,7 +1071,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
- name: Trigger Analytics Platform Temporal Worker Cloud deployment
@@ -1086,7 +1092,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
# The path list for this worker lives in the filter step above. This clause
@@ -1147,7 +1153,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
- name: Trigger Signup Enrichment Temporal Worker Cloud deployment
@@ -1168,7 +1174,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
# The product path list for this worker lives in the filter step above and
@@ -1214,7 +1220,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
- name: Trigger LLM Analytics Evals Temporal Worker Cloud deployment
@@ -1235,7 +1241,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
# NOTE: temporal-worker-llm-analytics rollout moved to cd-llm-analytics-image.yml
@@ -1259,7 +1265,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
- name: Trigger Logs Alerting Temporal Worker Cloud deployment
@@ -1280,7 +1286,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
- name: Trigger Stamphog Temporal Worker Cloud deployment
@@ -1301,7 +1307,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
- name: Trigger DuckLake Temporal Worker Cloud deployment
@@ -1322,7 +1328,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
- name: Trigger Data Warehouse Temporal Worker Cloud deployment
@@ -1343,7 +1349,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
- name: Trigger Warehouse Sources Load Cloud deployment
@@ -1364,7 +1370,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
- name: Trigger Data Warehouse CDP Producer Temporal Worker Cloud deployment
@@ -1385,7 +1391,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
- name: Trigger Data Warehouse Modeling Temporal Worker Cloud deployment
@@ -1406,7 +1412,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ steps.labels.outputs.labels }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
- name: Trigger Dagster Code Location Reload
@@ -1426,7 +1432,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ toJson(steps.labels.outputs.labels) }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
# Main image plus the inbox-ranking dependency group, for the inbox ranking training code
@@ -1437,7 +1443,7 @@ jobs:
dagster_ml_build:
name: Build and push Dagster ML image
needs: posthog_build
- if: ${{ needs.posthog_build.result == 'success' && needs.posthog_build.outputs.image-digest != '' && github.repository_owner == 'PostHog' && vars.CD_DEPLOY_ENABLED == 'true' && github.ref == 'refs/heads/master' }}
+ if: ${{ !cancelled() && needs.posthog_build.result == 'success' && needs.posthog_build.outputs.image-digest != '' && github.repository_owner == 'PostHog' && vars.CD_DEPLOY_ENABLED == 'true' && github.ref == 'refs/heads/master' }}
runs-on: depot-ubuntu-24.04
timeout-minutes: 30
continue-on-error: true
@@ -1462,6 +1468,12 @@ jobs:
- name: Check out
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ - name: Resolve commit timestamp
+ id: commit-time
+ env:
+ HEAD_COMMIT_TIMESTAMP: ${{ github.event.head_commit.timestamp }}
+ run: echo "timestamp=${HEAD_COMMIT_TIMESTAMP:-$(TZ=UTC git show -s --date=format-local:%Y-%m-%dT%H:%M:%SZ --format=%cd HEAD)}" >> "$GITHUB_OUTPUT"
+
- name: Set up Depot CLI
uses: depot/setup-action@15c09a5f77a0840ad4bce955686522a257853461 # v1.7.1
@@ -1561,7 +1573,7 @@ jobs:
"commit": ${{ toJson(github.event.head_commit) }},
"repository": "PostHog/posthog",
"labels": ${{ toJson(steps.labels.outputs.labels || '[]') }},
- "timestamp": "${{ github.event.head_commit.timestamp }}"
+ "timestamp": "${{ steps.commit-time.outputs.timestamp }}"
}
- name: Warn when the ML image failed
@@ -1571,10 +1583,9 @@ jobs:
ordered_image_alias:
name: Publish ordered image alias
needs: posthog_build
- if: ${{ needs.posthog_build.result == 'success' && github.repository_owner == 'PostHog' && vars.CD_DEPLOY_ENABLED == 'true' && vars.ORDERED_IMAGE_ALIAS_PAUSED != 'true' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
+ if: ${{ !cancelled() && needs.posthog_build.result == 'success' && github.repository_owner == 'PostHog' && vars.CD_DEPLOY_ENABLED == 'true' && vars.ORDERED_IMAGE_ALIAS_PAUSED != 'true' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
runs-on: ubuntu-24.04
timeout-minutes: 5
- continue-on-error: true
permissions:
id-token: write
contents: read
@@ -1612,6 +1623,7 @@ jobs:
uses: aws-actions/amazon-ecr-login@f2e9fc6c2b355c1890b65e6f6f0e2ac3e6e22f78 # v2.1.2
- name: Publish and read back ordered image alias
+ id: publish-alias
if: ${{ steps.ordered-release.outputs.tag != '' }}
timeout-minutes: 2
shell: bash
@@ -1622,3 +1634,11 @@ jobs:
ORDERED_ALIAS: ${{ steps.ordered-release.outputs.tag }}
REGCTL: ${{ runner.temp }}/regctl
run: bash .github/scripts/ordered-image-release.sh publish
+
+ - name: Fail when the ordered image alias is missing
+ if: ${{ steps.ordered-release.outputs.tag == '' || steps.publish-alias.outputs.outcome != 'present-at-expected-digest' }}
+ env:
+ OUTCOME: ${{ steps.publish-alias.outputs.outcome || 'not published' }}
+ run: |
+ echo "::error title=Ordered image alias missing::Kargo only creates freight from the ordered alias, so Kargo-delivered apps stay on the previous image (outcome: ${OUTCOME})."
+ exit 1
diff --git a/tools/hogli-commands/hogli_commands/tests/test_workflow_lint.py b/tools/hogli-commands/hogli_commands/tests/test_workflow_lint.py
index cbfb940904de..3020b3a0c542 100644
--- a/tools/hogli-commands/hogli_commands/tests/test_workflow_lint.py
+++ b/tools/hogli-commands/hogli_commands/tests/test_workflow_lint.py
@@ -33,6 +33,7 @@ from hogli_commands.workflow_lint.checks.checkout_full_depth import CheckoutFull
from hogli_commands.workflow_lint.checks.dorny_negation import DornyNegationCheck
from hogli_commands.workflow_lint.checks.job_timeouts import JobTimeoutsCheck
from hogli_commands.workflow_lint.checks.mcp_filter_coverage import McpFilterCoverageCheck, _resolve
+from hogli_commands.workflow_lint.checks.paused_public_image_pulls import PausedPublicImagePullsCheck
from hogli_commands.workflow_lint.checks.pinned_runner_images import PinnedRunnerImagesCheck
from hogli_commands.workflow_lint.checks.pr_concurrency import PrConcurrencyCheck
from hogli_commands.workflow_lint.checks.pr_event_fanout import PrEventFanoutCheck
@@ -2799,3 +2800,79 @@ class TestShellSplitActionArgsCheck:
issues = check.run(list(read_workflows(workflows_dir))).issues
assert issues == [], [issue.render() for issue in issues]
assert derive_shell_split_inputs(REPO_ROOT) == SHELL_SPLIT_INPUTS
+
+
+# ---------------------------------------------------------------------------
+# PausedPublicImagePullsCheck
+# ---------------------------------------------------------------------------
+
+
+def _image_job(push_to_ghcr: str, verify_step: str) -> str:
+ return f"""
+ name: x
+ on: [push]
+ jobs:
+ build:
+ runs-on: ubuntu-latest
+ timeout-minutes: 5
+ steps:
+ - id: docker-meta
+ uses: ./.github/actions/docker-meta
+ with:
+ image-name: app
+ push-to-ghcr: {push_to_ghcr}
+{textwrap.indent(textwrap.dedent(verify_step).strip(), " " * 10)}
+ """
+
+
+PAUSABLE = "${{ vars.PUBLIC_IMAGE_PUSH_PAUSED != 'true' }}"
+
+
+class TestPausedPublicImagePullsCheck:
+ @pytest.mark.parametrize(
+ "verify_step",
+ [
+ pytest.param(
+ """
+ - env:
+ IMAGE: ghcr.io/posthog/app:${{ github.sha }}
+ run: docker pull "$IMAGE"
+ """,
+ id="ghcr-via-env",
+ ),
+ pytest.param("- run: docker run --rm posthog/app:latest true", id="dockerhub-inline"),
+ pytest.param("- run: docker buildx imagetools inspect docker.io/posthog/app:latest", id="imagetools"),
+ ],
+ )
+ def test_flags_public_reads_when_push_can_pause(self, tmp_path: Path, verify_step: str) -> None:
+ _write(tmp_path, "wf.yml", _image_job(PAUSABLE, verify_step))
+ issues = PausedPublicImagePullsCheck().run(_read_all(tmp_path)).issues
+ assert len(issues) == 1, [i.render() for i in issues]
+ assert issues[0].job == "build"
+
+ @pytest.mark.parametrize(
+ "push_to_ghcr, verify_step",
+ [
+ pytest.param(
+ PAUSABLE,
+ """
+ - env:
+ IMAGE: ${{ steps.docker-meta.outputs.ecr-registry }}/app@${{ steps.image.outputs.digest }}
+ run: docker pull "$IMAGE"
+ """,
+ id="ecr-by-digest",
+ ),
+ pytest.param("'true'", "- run: docker pull ghcr.io/posthog/app:latest", id="push-never-pauses"),
+ pytest.param(
+ PAUSABLE,
+ """
+ - run: |
+ echo "tags=ghcr.io/posthog/app:1.0" >> "$GITHUB_OUTPUT"
+ """,
+ id="tag-list-not-a-read",
+ ),
+ ],
+ )
+ def test_passes(self, tmp_path: Path, push_to_ghcr: str, verify_step: str) -> None:
+ _write(tmp_path, "wf.yml", _image_job(push_to_ghcr, verify_step))
+ assert PausedPublicImagePullsCheck().run(_read_all(tmp_path)).issues == []
diff --git a/tools/hogli-commands/hogli_commands/workflow_lint/checks/__init__.py b/tools/hogli-commands/hogli_commands/workflow_lint/checks/__init__.py
index 859ff3d27010..0f4b7dd2cb7d 100644
--- a/tools/hogli-commands/hogli_commands/workflow_lint/checks/__init__.py
+++ b/tools/hogli-commands/hogli_commands/workflow_lint/checks/__init__.py
@@ -17,6 +17,7 @@ from .checkout_full_depth import CheckoutFullDepthCheck
from .dorny_negation import DornyNegationCheck
from .job_timeouts import JobTimeoutsCheck
from .mcp_filter_coverage import McpFilterCoverageCheck
+from .paused_public_image_pulls import PausedPublicImagePullsCheck
from .pinned_runner_images import PinnedRunnerImagesCheck
from .pr_concurrency import PrConcurrencyCheck
from .pr_event_fanout import PrEventFanoutCheck
@@ -40,6 +41,7 @@ CHECKS: list[WorkflowCheck] = [
PinnedRunnerImagesCheck(),
ShellSplitActionArgsCheck(),
StorybookStaticDirsCoverageCheck(),
+ PausedPublicImagePullsCheck(),
]
diff --git a/tools/hogli-commands/hogli_commands/workflow_lint/checks/paused_public_image_pulls.py b/tools/hogli-commands/hogli_commands/workflow_lint/checks/paused_public_image_pulls.py
new file mode 100644
index 000000000000..f377bf28d0b7
--- /dev/null
+++ b/tools/hogli-commands/hogli_commands/workflow_lint/checks/paused_public_image_pulls.py
@@ -0,0 +1,70 @@
+from __future__ import annotations
+
+import re
+
+from ..check import CheckResult, Issue, WorkflowCheck
+from ..model import Job, Step, Workflow
+
+PAUSE_VARIABLE = "PUBLIC_IMAGE_PUSH_PAUSED"
+PUBLIC_PUSH_INPUTS = ("push-to-ghcr", "push-to-dockerhub")
+DOCKER_META_ACTION = "./.github/actions/docker-meta"
+PUBLIC_IMAGE_RE = re.compile(r"\b(?:ghcr\.io|docker\.io)/[\w.-]+/[\w.-]+|(?<![\w./-])posthog/[\w.-]+[:@]")
+IMAGE_READ_RE = re.compile(
+ r"\bdocker\s+(?:image\s+)?(?:pull|run|create)\b|\bimagetools\s+(?:inspect|create)\b|\b(?:crane|skopeo)\s"
+)
+
+
+def _pauses_public_push(step: Step) -> bool:
+ if step.uses != DOCKER_META_ACTION or step.with_ is None:
+ return False
+ return any(PAUSE_VARIABLE in str(step.with_.get(name, "")) for name in PUBLIC_PUSH_INPUTS)
+
+
+def _step_strings(step: Step) -> list[str]:
+ if step.run is None or not IMAGE_READ_RE.search(step.run):
+ return []
+ env = step.raw.get("env")
+ return [step.run, *(str(value) for value in env.values())] if isinstance(env, dict) else [step.run]
+
+
+def _public_image_refs(step: Step) -> list[str]:
+ return sorted({match.group(0) for value in _step_strings(step) for match in PUBLIC_IMAGE_RE.finditer(value)})
+
+
+def _job_pauses_public_push(job: Job) -> bool:
+ return any(_pauses_public_push(step) for step in job.steps)
+
+
+class PausedPublicImagePullsCheck(WorkflowCheck):
+ id = "WF014-paused-public-image-pulls"
+ label = "paused public image pulls"
+ description = f"jobs that can pause public image pushes ({PAUSE_VARIABLE}) never read images from public registries"
+
+ @property
+ def fix_hint(self) -> str | None:
+ return (
+ f"While {PAUSE_VARIABLE} is set the public tags are never pushed, so this step fails. "
+ "Reference the image in ECR by digest instead, e.g. "
+ "`${{ steps.docker-meta.outputs.ecr-registry }}/<repository>@<digest>`."
+ )
+
+ def run(self, workflows: list[Workflow]) -> CheckResult:
+ result = CheckResult()
+ for wf in workflows:
+ for job in wf.jobs:
+ if not _job_pauses_public_push(job):
+ continue
+ for step in job.steps:
+ if step.uses == DOCKER_META_ACTION:
+ continue
+ for ref in _public_image_refs(step):
+ result.issues.append(
+ Issue(
+ workflow=wf.path.name,
+ job=job.name,
+ step=step.ref,
+ message=f"reads public image `{ref}`, which is absent while {PAUSE_VARIABLE} is set",
+ file=str(wf.path),
+ )
+ )
+ return result