This does not work because it happens after the code that fails because it cannot retrieve the version. What worked was to create a version.template.yml next to web.template.yml with the following content:
params:
home: /var/www/discourse
run:
- exec:
cd: $home
hook: code
cmd:
- git fetch --tags
And then include this file in containers/app.yml, before web.template.yml like so:
templates:
- "templates/postgres.template.yml"
- "templates/redis.template.yml"
- "templates/version.template.yml"
- "templates/web.template.yml"