Skip to content

Build Debian images for PDNS CI #392

Build Debian images for PDNS CI

Build Debian images for PDNS CI #392

name: Build Debian images for PDNS CI
on:
workflow_dispatch:
push:
pull_request:
schedule:
- cron: '0 23 * * *'
jobs:
build-and-push-debian-images:
strategy:
matrix:
branch-name:
- master
- rel/auth-4.9.x
- rel/dnsdist-1.9.x
image:
- id: debian-11-pdns-base
debian-image-name: python
debian-image-tag: 3.11-slim-bullseye
- id: debian-12-pdns-base
debian-image-name: debian
debian-image-tag: bookworm-slim
fail-fast: false
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- run: |
echo "image-id-lowercase=ghcr.io/${{ github.repository }}/${{ matrix.image.id }}" | tr '[:upper:]' '[:lower:]' >> "$GITHUB_ENV"
echo "image-tag=$(echo ${{ matrix.branch-name }} | cut -d '/' -f 2)" >> "$GITHUB_ENV"
- name: Build image
run: |
docker build . --file Dockerfile \
--tag ${{ env.image-id-lowercase }}:${{ env.image-tag }} \
--build-arg DEBIAN_IMAGE_NAME=${{ matrix.image.debian-image-name }} \
--build-arg DEBIAN_IMAGE_TAG=${{ matrix.image.debian-image-tag }} \
--build-arg REPO_BRANCH=${{ matrix.branch-name }}
- name: Login to GitHub Container Registry
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push into Github Container Registry
if: ${{ github.event_name != 'pull_request' }}
run: |
docker push ${{ env.image-id-lowercase }}:${{ env.image-tag }}
purge-old-images:
name: Purge old PDNS CI images
needs: build-and-push-debian-images
runs-on: ubuntu-22.04
if: ${{ github.event_name != 'pull_request' }}
permissions:
contents: read
packages: write
strategy:
matrix:
image-id:
- debian-11-pdns-base
- debian-12-pdns-base
fail-fast: false
steps:
- name: Get repository name
run: |
echo "${{ github.repository }}" | awk -F'/' '{print "repo-name="$2}' >> "$GITHUB_ENV"
- name: Purge old images keeping the 5 more recent ones
# FIXME: move to tag v5 when available.
uses: actions/[email protected]
with:
package-name: ${{ env.repo-name }}/${{ matrix.image-id }}
package-type: container
min-versions-to-keep: 5
delete-only-untagged-versions: true