Skip to content

ci(sign-object): harden the image release (tags, labels, nonroot, provenance) #27

ci(sign-object): harden the image release (tags, labels, nonroot, provenance)

ci(sign-object): harden the image release (tags, labels, nonroot, provenance) #27

Workflow file for this run

name: Build sign-object image
on:
push:
branches: [main, feat/signature-verification]
paths:
- 'cmd/sign-object/**'
- 'pkg/signature/**'
- 'pkg/signature/profiles/**'
- 'go.mod'
- 'go.sum'
pull_request:
paths:
- 'cmd/sign-object/**'
- 'pkg/signature/**'
- 'pkg/signature/profiles/**'
workflow_dispatch:
inputs:
IMAGE_TAG:
required: false
type: string
default: 'latest'
description: 'Image tag for the sign-object image'
permissions:
packages: write
contents: read
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/sign-object
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Docker metadata (tags + OCI labels)
id: meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha
type=raw,value=${{ inputs.IMAGE_TAG }},enable=${{ github.event_name == 'workflow_dispatch' && inputs.IMAGE_TAG != '' }}
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=pr
labels: |
org.opencontainers.image.title=sign-object
org.opencontainers.image.description=CLI to sign and verify Kubescape ApplicationProfile / NetworkNeighborhood / Rules objects (cosign, key-based or keyless).
org.opencontainers.image.licenses=Apache-2.0
org.opencontainers.image.source=https://github.com/${{ github.repository }}
- uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
- uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
if: github.event_name != 'pull_request'
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
with:
context: .
file: cmd/sign-object/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
provenance: true
sbom: true
cache-from: type=gha
cache-to: type=gha,mode=max
push: ${{ github.event_name != 'pull_request' }}