Skip to content

libovsdb-images

libovsdb-images #434

Workflow file for this run

name: libovsdb-images
on:
workflow_dispatch:
push:
branches: [main]
paths:
- .github/workflows/images.yml
- ovs/**
pull_request:
paths:
- .github/workflows/images.yml
- ovs/**
schedule:
# run weekly to ensure our copy of ovs is up-to-date
- cron: "42 0 * * 0"
env:
REGISTRY: ghcr.io
IMAGE_NAME: ovn-kubernetes/ovs
jobs:
build:
name: Build
if: github.repository == 'ovn-kubernetes/libovsdb'
strategy:
matrix:
image:
- ovs_version: master
tag: latest
- ovs_version: v3.5.0
tag: 3.5.0
- ovs_version: v3.4.0
tag: 3.4.0
- ovs_version: v3.3.0
tag: 3.3.0
arch: [linux/amd64, linux/arm64]
runs-on: ${{ matrix.arch == 'linux/arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
steps:
- name: Prepare
run: |
arch=${{ matrix.arch }}
echo "ARCH_VERSION_TUPLE=${{ matrix.image.tag }}-${arch//\//-}" >> $GITHUB_ENV
- name: Check Out Repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push by digest (push)
if: github.event_name != 'pull_request'
id: build
uses: docker/build-push-action@v6
with:
context: ovs
build-args: OVS_VERSION=${{ matrix.image.ovs_version }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: ${{ matrix.arch }}
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
- name: Build and push by digest (no push)
if: github.event_name == 'pull_request'
id: build-nopush
uses: docker/build-push-action@v6
with:
context: ovs
build-args: OVS_VERSION=${{ matrix.image.ovs_version }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: ${{ matrix.arch }}
outputs: type=image,push-by-digest=true,name-canonical=true,push=false
- name: Export digest
if: github.event_name != 'pull_request'
run: |
mkdir -p ${{ runner.temp }}/digests
digest="${{ steps.build.outputs.digest }}"
echo "${digest}" > "${{ runner.temp }}/digests/${{ env.ARCH_VERSION_TUPLE }}.digest"
- name: Upload digest
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.ARCH_VERSION_TUPLE }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1
manifest:
name: Create and Push Multi-Arch Manifest
needs: build
runs-on: ubuntu-latest
if: github.repository == 'ovn-kubernetes/libovsdb' && github.event_name != 'pull_request'
strategy:
matrix:
image:
- tag: latest
- tag: 3.5.0
- tag: 3.4.0
- tag: 3.3.0
steps:
- name: Download digests
uses: actions/download-artifact@v5
with:
path: ${{ runner.temp }}/digests
pattern: digests-${{ matrix.image.tag }}-*
merge-multiple: true
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Create and push manifest
run: |
DIGESTS=$(find ${{ runner.temp }}/digests -name '${{ matrix.image.tag }}-*.digest' -exec cat {} \; | tr '\n' ' ')
docker buildx imagetools create \
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.image.tag }} \
$(for d in $DIGESTS; do echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${d}"; done)