Skip to content

Commit 0265dff

Browse files
committed
Display version information in test application
1 parent 2f9acc4 commit 0265dff

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

.github/workflows/app.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ jobs:
3636
with:
3737
context: .
3838
file: app/Dockerfile
39+
build-args:
40+
GIT_COMMIT_ID: ${{ github.sha }}
3941
tags: ${{ steps.meta.outputs.tags }}
4042
labels: ${{ steps.meta.outputs.labels }}
4143
push: true

app/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
FROM phpdockerio/php:8.4-fpm
22
WORKDIR /application
33

4+
ARG GIT_COMMIT_ID=""
5+
46
# Install selected extensions and other stuff
57
RUN apt-get update \
68
&& apt-get -y --no-install-recommends install \
@@ -24,4 +26,6 @@ RUN composer install --no-dev --no-scripts; \
2426
composer dump-autoload --optimize --classmap-authoritative; \
2527
bin/console cache:warmup; \
2628
chown -R www-data:www-data ./var/; \
27-
chown -R www-data:www-data ./data/
29+
chown -R www-data:www-data ./data; \
30+
echo "VERSION_COMMIT_ID=${GIT_COMMIT_ID}" >> .env \
31+
date +"VERSION_DATE=\"%Y-%m-%d %H:%M:%S\"" >> .env

app/config/packages/twig.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,9 @@
1111
],
1212
'debug' => '%kernel.debug%',
1313
'strict_variables' => '%kernel.debug%',
14+
'globals' => [
15+
'VERSION_COMMIT_ID' => '%env(default::VERSION_COMMIT_ID)%',
16+
'VERSION_DATE' => '%env(default::VERSION_DATE)%',
17+
],
1418
]);
1519
};

app/templates/base.html.twig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,10 @@
2424
<main>
2525
{% block body %}{% endblock %}
2626
</main>
27+
{% if VERSION_COMMIT_ID %}
28+
<footer>
29+
Version: <a href="https://github.com/scheb/2fa/commit/{{ VERSION_COMMIT_ID }}">{{ VERSION_COMMIT_ID|slice(0, 7) }}</a>, Build: {{ VERSION_DATE }}
30+
</footer>
31+
{% endif %}
2732
</body>
2833
</html>

0 commit comments

Comments
 (0)