Skip to content

Commit

Permalink
Inject version into /about page
Browse files Browse the repository at this point in the history
  • Loading branch information
ku1ik committed Nov 14, 2024
1 parent a087ca4 commit 1ef6a89
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ jobs:
[[ "${{ github.ref_type }}" == "tag" ]] && IMAGE_TAG=$(echo $IMAGE_TAG | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$IMAGE_TAG" == "main" ] && IMAGE_TAG=latest
VERSION="${{ github.sha }}"
[[ "${{ github.ref_type }}" == "tag" ]] && VERSION="${{ github.ref_name }}"
[[ "${{ github.ref_type }}" == "branch" ]] && VERSION="${{ github.ref_name }}-${{ github.sha }}"
echo IMAGE_ID=$IMAGE_ID >> $GITHUB_OUTPUT
echo IMAGE_TAG=$IMAGE_TAG >> $GITHUB_OUTPUT
echo VERSION=$VERSION >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -46,6 +50,8 @@ jobs:

- name: Build image
uses: docker/build-push-action@v5
env:
VERSION: "${{ steps.vars.outputs.VERSION }}"
with:
context: .
push: true
Expand Down
2 changes: 2 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# General application configuration
import Config

config :asciinema, version: System.get_env("VERSION")

config :asciinema, :session_opts,
store: :cookie,
key: "_asciinema_key",
Expand Down
3 changes: 2 additions & 1 deletion lib/asciinema_web/controllers/page_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ defmodule AsciinemaWeb.PageController do
"about.html",
page_title: "About",
contact_email_address: Application.get_env(:asciinema, :contact_email_address),
server_name: AsciinemaWeb.Endpoint.host()
server_name: AsciinemaWeb.Endpoint.host(),
server_version: Application.get_env(:asciinema, :version)
)
end

Expand Down
9 changes: 7 additions & 2 deletions lib/asciinema_web/controllers/page_html/about.html.heex
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<h1>About <%= @server_name %></h1>

<p>
<strong><%= @server_name %></strong> is a platform for hosting and sharing
terminal session recordings, powered by <a href="https://docs.asciinema.org/manual/server/">asciinema server</a>.
<strong><%= @server_name %></strong>
is a platform for hosting and sharing
terminal session recordings, powered by
<a href="https://docs.asciinema.org/manual/server/">asciinema server</a>
<%= if @server_version do %>
(<%= @server_version %>)
<% end %>.
</p>

<%= if @contact_email_address do %>
Expand Down

0 comments on commit 1ef6a89

Please sign in to comment.