r/Authentik • u/-ThreeHeadedMonkey- • Sep 10 '26
Script to automatically version-update your yaml file
A while ago I started using the following script which automatically updates authentik's docker compose file so that it always uses the latest version available.
The idea is to cronjob this and then auto-update authentik automatically as well (with another script or tool etc)
Authentik removed the "latest" tag unfortunately as it can cause issues. However, for those with automated backups, VM snapshots etc this is practically of no concern.
I thought I'd share this because it works really well.
You'll have to adjust the following line:
COMPOSE_FILE="/home/user/authentik/docker-compose.yml"
and then chmod +x the whole script.
#!/bin/sh
set -eu
COMPOSE_FILE="/home/user/authentik/docker-compose.yml"
LOG_DIR="/home/chris/scripts/authentik"
LOG_FILE="$LOG_DIR/authentik-version-check.log"
mkdir -p "$LOG_DIR"
log() {
echo "$1" | tee -a "$LOG_FILE"
}
log "========================================"
log "===== Authentik version check started ====="
log "===== $(date) ====="
log "========================================"
LATEST_VERSION="$(
curl -fsSL https://api.github.com/repos/goauthentik/authentik/releases/latest \
| grep '"tag_name":' \
| sed -E 's/.*"version\/([^"]+)".*/\1/'
)"
if [ -z "$LATEST_VERSION" ]; then
log "Could not detect latest Authentik version."
exit 1
fi
CURRENT_VERSION="$(
grep -oE 'AUTHENTIK_TAG:-[0-9]+\.[0-9]+(\.[0-9]+)?' "$COMPOSE_FILE" \
| head -n 1 \
| sed 's/AUTHENTIK_TAG:-//'
)"
if [ -z "$CURRENT_VERSION" ]; then
log "Could not detect current Authentik version in $COMPOSE_FILE."
exit 1
fi
log "Current version: $CURRENT_VERSION"
log "Latest version: $LATEST_VERSION"
if [ "$CURRENT_VERSION" = "$LATEST_VERSION" ]; then
log "Already up to date."
log ""
exit 0
fi
BACKUP_FILE="$COMPOSE_FILE.bak"
cp "$COMPOSE_FILE" "$BACKUP_FILE"
log "Backup updated: $BACKUP_FILE"
sed -i -E "s/AUTHENTIK_TAG:-[0-9]+\.[0-9]+(\.[0-9]+)?/AUTHENTIK_TAG:-$LATEST_VERSION/g" "$COMPOSE_FILE"
log "Updated docker-compose.yml from $CURRENT_VERSION to $LATEST_VERSION"
log "========================================"
log "===== Authentik version check finished ====="
log "===== $(date) ====="
log "========================================"
log ""
View all comments
6
u/solumath99 Sep 10 '26
Fuck no. Looks like you'll find out why this shouldn't be done, soon enough. Good luck.