Website version with Travis CI

Here is a simple head snippet to show what is the version (= abbreviated commit) of your site deployed with Travis CI, provided a PRODUCTION environment variable is set to true:

{{ with (getenv "PRODUCTION") }}
  <meta name="version" content="{{ substr (getenv "TRAVIS_COMMIT") 0 7 }}">
{{ end }}
2 Likes

Travis and other CIs also has a env var called “CI”, so this should also work:

{{ with (getenv “CI”) }

1 Like