Skip to content

Build Debian images for PDNS CI #47

Build Debian images for PDNS CI

Build Debian images for PDNS CI #47

name: Build Debian images for PDNS CI
on:
workflow_dispatch:
push:
pull_request:
schedule:
- cron: '0 23 * * *'
env:
IMAGE_TAG: master
jobs:
build-and-push-debian-images:
strategy:
matrix:
include:
- image-id: debian-11-pdns-base
debian-release-name: bullseye-slim
- image-id: debian-12-pdns-base
debian-release-name: bookworm-slim
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- run: |
echo "image-id-lowercase=ghcr.io/${{ github.repository }}/${{ matrix.image-id }}" | tr '[:upper:]' '[:lower:]' >> "$GITHUB_ENV"
- name: Build image
run: |
docker build . --file Dockerfile \
--tag ${{ env.image-id-lowercase }}:${{ env.IMAGE_TAG }} \
--build-arg DEBIAN_IMAGE_TAG=${{ matrix.debian-release-name }}
- name: Login to GitHub Container Registry
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v2
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
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
uses: actions/delete-package-versions@v4
with:
package-name: ${{ env.repo-name }}/${{ matrix.image-id }}
package-type: container
min-versions-to-keep: 5