Skip to content

Publish and Sign Container Image #161

Publish and Sign Container Image

Publish and Sign Container Image #161

Workflow file for this run

name: Publish and Sign Container Image
on: workflow_dispatch
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install cosign
uses: sigstore/[email protected]
- name: Check install!
run: cosign version
- name: Log into ghcr.io
uses: docker/login-action@master
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: distroless/actions/apko-build@main
with:
config: foo.yaml
tag: ghcr.io/${{ github.repository }}:latest
- uses: distroless/actions/apko-publish@main
id: push-step
with:
config: foo.yaml
tag: ghcr.io/${{ github.repository }}:latest
- name: Sign the images with GitHub OIDC Token
env:
COSIGN_EXPERIMENTAL: "true"
run: |
echo "dont sign image"
cosign sign --yes ${{ steps.push-step.outputs.digest }}
- name: (optional) Verify the images
run: |
cosign verify ghcr.io/whoissqr/cg-test-keyless-sign \
--certificate-identity https://github.com/whoissqr/cg-test-keyless-sign/.github/workflows/main.yml@refs/heads/main \
--certificate-oidc-issuer https://token.actions.githubusercontent.com | jq
- name: (optional) Install Kyverno CLI
if: always()
uses: kyverno/[email protected]
- name: (optional) Dry run policy using Kyverno CLI
if: always()
run: |
kyverno version
kyverno apply ./k3s/policy-check-image-keyless.yaml --resource ./k3s/pod.yaml
# kubectl get clusterpolicies -o yaml | kyverno apply - --resource ./k3s/pod.yaml -v 10
- name: Create k3s cluster
uses: debianmaster/actions-k3s@master
id: k3s
with:
version: 'latest'
- name: Install Kyverno chart
run: |
helm repo add kyverno https://kyverno.github.io/kyverno/
helm repo update
helm install --atomic kyverno kyverno/kyverno -n kyverno --create-namespace
sleep 10
- name: Apply image attestation policy
run: |
kubectl apply -f ./k3s/policy-check-image-keyless.yaml
- name: Deploy pod to k3s
if: always()
run: |
set -x
kubectl create ns app
kubectl apply -f ./k3s/pod.yaml
kubectl get pod -n app
kubectl describe pod cg -n app
kubectl -n app wait --for=condition=Ready --timeout=60s pod/cg
kubectl describe pod cg -n app
kubectl get pods -n app