Add a ping page with the commit sha

This commit is contained in:
Gabriel Augendre 2023-03-25 21:06:04 +01:00
parent b691551e5b
commit a697b3a6f1
6 changed files with 47 additions and 3 deletions

View File

@ -50,4 +50,4 @@ jobs:
max_attempts: 5
retry_wait_seconds: 2
warning_on_retry: false
command: curl -sSL --fail -m 10 https://checkout.augendre.info | grep ${GITHUB_SHA::7} > /dev/null
command: curl -sSL --fail -m 10 https://checkout.augendre.info/ping/ | grep ${GITHUB_SHA::7} > /dev/null

View File

@ -129,6 +129,7 @@ TEMPLATES = [
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"common.context_processors.app",
],
},
},
@ -228,3 +229,26 @@ CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5"
CRISPY_TEMPLATE_PACK = "bootstrap5"
MESSAGE_TAGS = {messages.ERROR: "danger"}
APP = {
"build": {
"date": "latest-date",
"commit": "latest-commit",
"describe": "latest-describe",
},
}
try:
with Path("/app/git/build-date").open() as f:
APP["build"]["date"] = f.read().strip()
except Exception: # noqa: S110
pass
try:
with Path("/app/git/git-commit").open() as f:
APP["build"]["commit"] = f.read().strip()
except Exception: # noqa: S110
pass
try:
with Path("/app/git/git-describe").open() as f:
APP["build"]["describe"] = f.read().strip()
except Exception: # noqa: S110
pass

View File

@ -0,0 +1,5 @@
from django.conf import settings
def app(_):
return settings.APP

View File

@ -0,0 +1,10 @@
{% extends "common/base.html" %}
{% block content %}
<h1>Ping</h1>
<h2>Versions</h2>
<ul>
<li>Build date: {{ build.date }}</li>
<li>Commit: {{ build.commit }}</li>
<li>Version: {{ build.describe }}</li>
</ul>
{% endblock %}

View File

@ -1,8 +1,9 @@
from django.urls import path
from common.views import home
from common.views import home, ping
app_name = "common"
urlpatterns = [
path("ping/", ping, name="ping"),
path("", home, name="home"),
]

View File

@ -1,5 +1,9 @@
from django.shortcuts import redirect
from django.shortcuts import redirect, render
def home(_request):
return redirect("purchase:new")
def ping(request):
return render(request, "common/ping.html", {})