Skip to content

fix: Split local image build into build and publish workflows#730

Merged
lindnerby merged 5 commits into
kyma-project:mainfrom
medmes:feat/ghcr-image-builder-local
May 7, 2026
Merged

fix: Split local image build into build and publish workflows#730
lindnerby merged 5 commits into
kyma-project:mainfrom
medmes:feat/ghcr-image-builder-local

Conversation

@medmes
Copy link
Copy Markdown
Member

@medmes medmes commented May 6, 2026

Description

Addresses the pull_request_target supply-chain vulnerability flagged by GitHub code scanning after #711 was merged.

The single workflow is split into two:

  • build-image-local.yml: runs on pull_request (untrusted context, no secrets) — builds multi-arch OCI tarball and uploads as a GitHub Actions artifact
  • publish-image-local.yml: runs on workflow_run (privileged, base branch context) — downloads the pre-built artifact and pushes to ghcr.io via skopeo. Never checks out fork code.

This eliminates the risk of fork-controlled Dockerfile content executing in a context with packages: write.

Additional improvements over the baseline fix:

  • Guard against empty tags with an explicit error message
  • Push from OCI archive directly to all tags (no registry round-trip)
  • Print image digest in job summary for digest pinning

@medmes medmes requested a review from a team as a code owner May 6, 2026 15:37
medmes added 3 commits May 6, 2026 17:47
Adds image-builder-local.yml to build and publish runtime-watcher images
to ghcr.io/kyma-project/runtime-watcher for fast local testing on arm64
(Apple M-series) and amd64 machines.

Closes kyma-project#709
- Rename image-builder-local.yml → build-image-local.yml
- Remove draft PR guard — builds run for draft PRs too
- Rename workflow display name to "Build Image (Local testing / ghcr.io)"
Addresses the pull_request_target supply-chain vulnerability flagged by
GitHub code scanning. Follows the workflow_run split pattern:
- build-image-local.yml: runs on pull_request (untrusted, no secrets),
  builds multi-arch OCI tarball and uploads as artifact
- publish-image-local.yml: runs on workflow_run (privileged, never
  executes fork code), pushes tarball to ghcr.io via skopeo

Improvements over the original fix:
- Guard against empty tags with explicit error message
- Push from OCI archive directly to all tags (no registry round-trip)
- Print image digest in job summary for digest pinning
@medmes medmes force-pushed the feat/ghcr-image-builder-local branch from 72c6708 to 529b69d Compare May 6, 2026 15:47
@medmes medmes changed the title fix: split local image build into build and publish workflows fix: Split local image build into build and publish workflows May 6, 2026
Remove metadata.json from the build workflow entirely — fork code could
forge event_name/ref to hijack the :latest tag. Tag decisions are now
derived exclusively from github.event.workflow_run.* (trusted GitHub
context) in the publish workflow, which never executes untrusted code.
@medmes medmes assigned medmes and lindnerby and unassigned medmes May 7, 2026
Move workflow_run context values (head_branch, head_sha, event) from
inline ${{ }} expressions into env variables to prevent shell injection
via maliciously-named branches.
@lindnerby lindnerby enabled auto-merge (squash) May 7, 2026 15:02
@lindnerby lindnerby merged commit b7ccea7 into kyma-project:main May 7, 2026
14 checks passed
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