Skip to content

Docker

Docker #1479

Workflow file for this run

name: Docker
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
schedule:
- cron: '00 18 * * *'
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
LIBBPF_CI_TAG: v4
RUNNER_VERSION: 2.331.0
jobs:
build:
name: ${{ matrix.tag }}
runs-on: ${{ matrix.runs_on }}
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
strategy:
fail-fast: false
matrix:
include:
- arch: x86_64
dockerfile: Dockerfile
platform: linux/amd64
tag: main-noble-x86_64
runs_on: ubuntu-latest
- arch: aarch64
dockerfile: Dockerfile
platform: linux/arm64
tag: main-noble-aarch64
runs_on: ubuntu-24.04-arm
- arch: s390x
dockerfile: s390x.Dockerfile
platform: linux/s390x
tag: main-noble-s390x
runs_on: ubuntu-latest
- arch: x86_64
dockerfile: kbuilder-debian.Dockerfile
platform: linux/amd64
tag: kbuilder-debian-x86_64
runs_on: ubuntu-latest
- arch: aarch64
dockerfile: kbuilder-debian.Dockerfile
platform: linux/arm64
tag: kbuilder-debian-aarch64
runs_on: ubuntu-24.04-arm
steps:
- name: Checkout repository
uses: actions/checkout@v6
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@main
- name: Check cosign install!
if: github.event_name != 'pull_request'
run: cosign version
- name: Set up QEMU
if: matrix.arch == 's390x'
uses: docker/setup-qemu-action@v3
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.dockerfile }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.tag }}
platforms: ${{ matrix.platform }}
build-args: |
LIBBPF_CI_TAG=${{ env.LIBBPF_CI_TAG }}
RUNNER_VERSION=${{ env.RUNNER_VERSION }}
# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
COSIGN_EXPERIMENTAL: "true"
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: cosign sign --yes ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.tag }}