Skip to content

Commit 1ef6a89

Browse files
committed
Inject version into /about page
1 parent a087ca4 commit 1ef6a89

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

.github/workflows/publish.yml

+6
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ jobs:
3131
[[ "${{ github.ref_type }}" == "tag" ]] && IMAGE_TAG=$(echo $IMAGE_TAG | sed -e 's/^v//')
3232
# Use Docker `latest` tag convention
3333
[ "$IMAGE_TAG" == "main" ] && IMAGE_TAG=latest
34+
VERSION="${{ github.sha }}"
35+
[[ "${{ github.ref_type }}" == "tag" ]] && VERSION="${{ github.ref_name }}"
36+
[[ "${{ github.ref_type }}" == "branch" ]] && VERSION="${{ github.ref_name }}-${{ github.sha }}"
3437
echo IMAGE_ID=$IMAGE_ID >> $GITHUB_OUTPUT
3538
echo IMAGE_TAG=$IMAGE_TAG >> $GITHUB_OUTPUT
39+
echo VERSION=$VERSION >> $GITHUB_OUTPUT
3640
3741
- name: Set up Docker Buildx
3842
uses: docker/setup-buildx-action@v3
@@ -46,6 +50,8 @@ jobs:
4650

4751
- name: Build image
4852
uses: docker/build-push-action@v5
53+
env:
54+
VERSION: "${{ steps.vars.outputs.VERSION }}"
4955
with:
5056
context: .
5157
push: true

config/config.exs

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
# General application configuration
88
import Config
99

10+
config :asciinema, version: System.get_env("VERSION")
11+
1012
config :asciinema, :session_opts,
1113
store: :cookie,
1214
key: "_asciinema_key",

lib/asciinema_web/controllers/page_controller.ex

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ defmodule AsciinemaWeb.PageController do
99
"about.html",
1010
page_title: "About",
1111
contact_email_address: Application.get_env(:asciinema, :contact_email_address),
12-
server_name: AsciinemaWeb.Endpoint.host()
12+
server_name: AsciinemaWeb.Endpoint.host(),
13+
server_version: Application.get_env(:asciinema, :version)
1314
)
1415
end
1516

lib/asciinema_web/controllers/page_html/about.html.heex

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
<h1>About <%= @server_name %></h1>
22

33
<p>
4-
<strong><%= @server_name %></strong> is a platform for hosting and sharing
5-
terminal session recordings, powered by <a href="https://docs.asciinema.org/manual/server/">asciinema server</a>.
4+
<strong><%= @server_name %></strong>
5+
is a platform for hosting and sharing
6+
terminal session recordings, powered by
7+
<a href="https://docs.asciinema.org/manual/server/">asciinema server</a>
8+
<%= if @server_version do %>
9+
(<%= @server_version %>)
10+
<% end %>.
611
</p>
712

813
<%= if @contact_email_address do %>

0 commit comments

Comments
 (0)