Skip to content

Check docker base image for updates #399

Check docker base image for updates

Check docker base image for updates #399

name: Check docker base image for updates
on:
schedule:
- cron: '20 4 * * *' # every day at 420 am
workflow_dispatch:
env:
IMAGE_NAME: gnzsnz/apt-cacher-ng:latest
BASE_IMAGE: ubuntu:noble
PLATFORMS: linux/amd64,linux/arm64,linux/arm
jobs:
check_base:
runs-on: ubuntu-latest
outputs:
needs-updating: ${{ steps.check.outputs.needs-updating }}
steps:
- name: Check if update available
id: check
uses: lucacome/docker-image-update-checker@v1
with:
base-image: ${{ env.BASE_IMAGE }}
image: ${{ env.IMAGE_NAME}}
platforms: ${{ env.PLATFORMS }}
build:
runs-on: ubuntu-latest
needs: check_base
if: needs.check_base.outputs.needs-updating == 'true'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get enviroment variables
run: |
grep -v '#' .env-dist | grep '=' > .env
while IFS= read -r line; do
echo $line >> $GITHUB_ENV ;
done < .env
- name: Create issue
id: create_issue
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
title="Base images updates found for ${{ env.IMAGE_NAME }}:${{ env.IMAGE_VERSION }}"
body="A new build&publish might be needed."
exists=$(gh issue list -S "is:issue state:open in:title $title" | wc -l)
if [ -n "$exists" ] && [ "$exists" -gt 0 ]; then
echo "dup_issue=yes" >> $GITHUB_OUTPUT
else
gh issue create -t "$title" -b "$body"
echo "dup_issue=no" >> $GITHUB_OUTPUT
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
if: ${{ steps.create_issue.outputs.dup_issue == 'no' }}
with:
platforms: ${{ env.PLATFORMS }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
if: ${{ steps.create_issue.outputs.dup_issue == 'no' }}
- name: Build Docker image
uses: docker/build-push-action@v6
if: ${{ steps.create_issue.outputs.dup_issue == 'no' }}
with:
push: false
load: true
context: .
build-args: |
BASE_VERSION=${{ env.BASE_VERSION }}
IMAGE_VERSION=${{ env.IMAGE_VERSION }}
tags: ${{ env.IMAGE_NAME }}