Skip to content

APK Check Versions

APK Check Versions #48

---
name: APK Check Versions
on:
schedule:
- cron: "0 0 * * 0"
workflow_dispatch:
permissions: {}
jobs:
apk-check-versions:
permissions:
# Required to clone repo
contents: read
runs-on: ubuntu-latest
steps:
- name: Set IMAGE
shell: bash
run: |
set -euo pipefail
IFS=$'\n\t'
echo "IMAGE=${GITHUB_REPOSITORY#*/docker-}" >> "${GITHUB_ENV}"
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 1
persist-credentials: false
- name: Check the versions
shell: bash
run: |
set -euo pipefail
IFS=$'\n\t'
PINNED=$(awk -F= '/^[[:space:]]+[a-z0-9][a-z0-9._+-]*=[0-9]/ { gsub(/[[:space:]]/, "", $1); print $1 }' "${IMAGE}/Dockerfile")
if [ -z "${PINNED}" ]; then
echo "No pinned packages found in ${IMAGE}/Dockerfile" >&2
exit 1
fi
echo "Pinned packages:"
echo "${PINNED}"
UPGRADABLE=$(docker run --pull always --rm --user root --entrypoint /bin/sh "leplusorg/${IMAGE}:main" -c 'apk update >/dev/null 2>&1 && apk -u list 2>/dev/null')
OUTDATED=""
for pkg in ${PINNED}; do
if printf '%s\n' "${UPGRADABLE}" | grep -qE "^${pkg}-[0-9]"; then
OUTDATED="${OUTDATED} ${pkg}"
fi
done
if [ -n "${OUTDATED}" ]; then
echo "The following pinned packages are outdated:${OUTDATED}" >&2
exit 1
fi
echo "All pinned packages are up to date"