Skip to content

Commit

Permalink
ci: docker push: only push latest when required
Browse files Browse the repository at this point in the history
Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
  • Loading branch information
rissson committed Dec 18, 2024
1 parent 821f06f commit 4c6f4d5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/actions/docker-push-variables/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ runs:
IMAGE_ARCH: ${{ inputs.image-arch }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
pip3 install requests
python3 ${{ github.action_path }}/push_vars.py
15 changes: 14 additions & 1 deletion .github/actions/docker-push-variables/push_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import configparser
import os
import requests
from time import time

parser = configparser.ConfigParser()
Expand Down Expand Up @@ -29,6 +30,15 @@

sha = os.environ["GITHUB_SHA"] if not is_pull_request else os.getenv("PR_HEAD_SHA")

latest_published_version = requests.get("https://version.goauthentik.io/version.json")
latest_published_version.raise_for_status()
# 2042.0.0
latest_published_version = latest_published_version.json()["stable"]["version"]
# 2042.0
latest_published_version_family = ".".join(
latest_published_version.split("-", 1)[0].split(".")[:-1]
)

# 2042.1.0 or 2042.1.0-rc1
version = parser.get("bumpversion", "current_version")
# 2042.1
Expand All @@ -42,8 +52,11 @@
f"{name}:{version}",
]
if not prerelease:
if latest_published_version_family == version_family or version[-1] == "0":
image_tags += [
f"{name}:latest",
]
image_tags += [
f"{name}:latest",
f"{name}:{version_family}",
]
else:
Expand Down

0 comments on commit 4c6f4d5

Please sign in to comment.