Skip to content

Check for updates

Check for updates #192

Workflow file for this run

name: Check for updates
on:
push:
branches:
- "*"
schedule:
- cron: 0 */6 * * *
workflow_dispatch:
jobs:
varnish_cache_check:
strategy:
matrix:
version:
- stable
- old
- fresh
name: Varnish Cache version check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Check version
run: |
V=$(sed -n 's/ARG *VARNISH_VERSION_NUMBER=//p' ${{ matrix.version }}/debian/Dockerfile)
# if fresh, we want the absolute latest version, otherwise we want the latest version with the same major/minor
if [ "${{ matrix.version }}" = "fresh" ]; then
FILTER="varnish=*"
else
FILTER="varnish=${V%.*}.*"
fi
echo "FILTER: $FILTER"
curl -Ls https://packages.varnish-software.com/varnish/bootstrap-deb.sh | sh
LATEST=$(apt-cache show "$FILTER" | sed -En 's/^Version: (.*)~.*/\1/p')
if [ "$LATEST" != "$V" ]; then
echo "We are targetting $V for ${{ matrix.version }}, but $LATEST is out"
exit 1
else
echo "We are properly targetting $LATEST"
fi
varnish_enterprise_check:
name: ${{ matrix.package.name }} version check
runs-on: ubuntu-latest
strategy:
matrix:
package:
- name: varnish-plus
var: VARNISH_PLUS_VERSION
- name: varnish-otel
var: VARNISH_OTEL_VERSION
env:
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check version
run: |
set -ex
cat << EOF > Dockerfile
FROM varnish/enterprise
USER root
RUN set -ex; \
apt-get update; \
apt-get install -y curl; \
curl -s https://packagecloud.io/install/repositories/varnishplus/60-enterprise/script.deb.sh | bash
EOF
docker build -t tester .
LATEST_VERSION=$(docker run --rm tester apt-cache show ${{ matrix.package.name }} | awk '$1 == "Version:" {print $2}' | sort -V | tail -1 | sed 's/~.*//')
CURRENT_VERSION=$(sed -n 's/^ARG ${{ matrix.package.var }}=//p' enterprise/debian/Dockerfile)
echo $LATEST_VERSION - $CURRENT_VERSION
echo "LATEST_VERSION=$LATEST_VERSION" >> "$GITHUB_ENV"
echo "CURRENT_VERSION=$CURRENT_VERSION" >> "$GITHUB_ENV"
if [ "$LATEST_VERSION" != "$CURRENT_VERSION" ]; then
echo "Current version is $CURRENT_VERSION, but it looks like $LATEST_VERSION is out"
exit 1
fi
- name: Create PR to update the Enterprise Dockerfile
if: failure()
run: |
set -ex
echo ${{ env.CURRENT_VERSION }} - ${{ env.LATEST_VERSION }}
BRANCH=auto-pr-enterprise-${{ env.LATEST_VERSION }}
if [ -n "$(git branch --list $BRANCH)" ]; then
echo "Branch $BRANCH already exist, bailing out"
exit 0
fi
git config --global user.email "none"
git config --global user.name "Github Actions"
git switch main
git switch -c $BRANCH
sed -i "s/${{ matrix.package.var }}=${{ env.CURRENT_VERSION }}/${{ matrix.package.var }}=${{ env.LATEST_VERSION }}/" enterprise/debian/Dockerfile
if [ -z "$(git diff)"]; then
echo "It looks like the Docker file is up-to-date, maybe the new image is being published right now?"
exit 0
fi
git commit enterprise/debian/Dockerfile -m "enterprise: upgrade ${{ matrix.package.name }} to ${{ env.LATEST_VERSION }}"
git push origin $BRANCH
gh pr create --title "enterprise: upgrade ${{ matrix.package.name }} to ${{ env.LATEST_VERSION }}" --body "Automated PR from .github/workflows/version_check.yml" --base main --head $BRANCH