Skip to content

Commit 3cafc46

Browse files
committed
ci(apk-check-versions): check only pinned versions
1 parent c88c04d commit 3cafc46

1 file changed

Lines changed: 32 additions & 1 deletion

File tree

.github/workflows/apk-check-versions.yml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,42 @@ permissions: {}
1010

1111
jobs:
1212
apk-check-versions:
13+
permissions:
14+
# Required to clone repo
15+
contents: read
1316
runs-on: ubuntu-latest
1417
steps:
18+
- name: Set IMAGE
19+
shell: bash
20+
run: |
21+
set -euo pipefail
22+
IFS=$'\n\t'
23+
echo "IMAGE=${GITHUB_REPOSITORY#*/docker-}" >> "${GITHUB_ENV}"
24+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
25+
with:
26+
fetch-depth: 1
27+
persist-credentials: false
1528
- name: Check the versions
1629
shell: bash
1730
run: |
1831
set -euo pipefail
1932
IFS=$'\n\t'
20-
docker run --pull always -t --user root --entrypoint /bin/sh "leplusorg/${GITHUB_REPOSITORY#*/docker-}:main" -c 'if apk update && apk -u list | tee -a /dev/stderr | grep -q -e .; then exit 1; fi'
33+
PINNED=$(awk -F= '/^[[:space:]]+[a-z0-9][a-z0-9._+-]*=[0-9]/ { gsub(/[[:space:]]/, "", $1); print $1 }' "${IMAGE}/Dockerfile")
34+
if [ -z "${PINNED}" ]; then
35+
echo "No pinned packages found in ${IMAGE}/Dockerfile" >&2
36+
exit 1
37+
fi
38+
echo "Pinned packages:"
39+
echo "${PINNED}"
40+
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')
41+
OUTDATED=""
42+
for pkg in ${PINNED}; do
43+
if printf '%s\n' "${UPGRADABLE}" | grep -qE "^${pkg}-[0-9]"; then
44+
OUTDATED="${OUTDATED} ${pkg}"
45+
fi
46+
done
47+
if [ -n "${OUTDATED}" ]; then
48+
echo "The following pinned packages are outdated:${OUTDATED}" >&2
49+
exit 1
50+
fi
51+
echo "All pinned packages are up to date"

0 commit comments

Comments
 (0)