Skip to content

Commit

Permalink
Add version to template and CI (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
uittenbroekrobbert authored Jun 17, 2024
2 parents 42eab5a + eb9ef7a commit 1cb169d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: get commit hash
id: get_commit_hash
run: |
echo "commit_hash=$(git describe --tags)" >> "$GITHUB_OUTPUT"
- name: Make changes to project to inject commit hash
run: |
sed -i 's/VERSION: str = .*$/VERSION: str = "${{ steps.get_commit_hash.outputs.commit_hash }}"/g' tad/core/config.py
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
Expand All @@ -168,6 +177,7 @@ jobs:
echo "tags: ${{ steps.meta.outputs.tags }}"
echo "labels: ${{ steps.meta.outputs.labels }}"
echo "annotations: ${{ steps.meta.outputs.annotations }}"
echo "hash: ${{ steps.get_commit_hash.outputs.commit_hash }}"
- name: Build and push Docker image
Expand Down
8 changes: 7 additions & 1 deletion tad/api/routes/deps.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
from fastapi import Request
from fastapi.templating import Jinja2Templates
from jinja2 import Environment

from tad.core.config import settings


def version_context_processor(request: Request):
return {"version": settings.VERSION}


env = Environment(
autoescape=True,
)
templates = Jinja2Templates(directory=settings.TEMPLATE_DIR, env=env)
templates = Jinja2Templates(directory=settings.TEMPLATE_DIR, context_processors=[version_context_processor], env=env)
3 changes: 2 additions & 1 deletion tad/site/templates/default_layout.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@
<div class="header_logo_container">
<img class="header_logo_image" src="/static/images/logo.svg"/>
<div class="header_subtitle_container">
<span>Transparency of Algorithmic Decision making (TAD)</span>
<span>Transparency of Algorithmic Decision making ({{ version }})</span>
</div>
</div>
</div>
<nav class="header_nav">

</nav>
</header>
<div class="container" hx-ext="response-targets">
Expand Down

0 comments on commit 1cb169d

Please sign in to comment.