Skip to content

Commit

Permalink
feat: expose APP_VERSION env var with HEAD commit sha
Browse files Browse the repository at this point in the history
  • Loading branch information
adamstankiewicz committed May 22, 2024
1 parent d034d2f commit 2826de8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tubular/scripts/frontend_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def get_app_config(self):
""" Combines the common and environment configs APP_CONFIG data """
app_config = self.common_cfg.get('APP_CONFIG', {})
app_config.update(self.env_cfg.get('APP_CONFIG', {}))
app_config['APP_VERSION'] = self.get_version_commit_sha()
if not app_config:
self.LOG('Config variables do not exist for app {}.'.format(self.app_name))
return app_config
Expand Down Expand Up @@ -139,12 +140,16 @@ def build_app(self, env_vars, fail_msg):
if build_return_code != 0:
self.FAIL(1, fail_msg)

def get_version_commit_sha(self):
""" Returns the commit SHA of the current HEAD """
return LocalGitAPI(Repo(self.app_name)).get_head_sha()

def create_version_file(self):
""" Creates a version.json file to be deployed with frontend """
# Add version.json file to build.
version = {
'repo': self.app_name,
'commit': LocalGitAPI(Repo(self.app_name)).get_head_sha(),
'commit': self.get_version_commit_sha(),
'created': datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
}
try:
Expand Down

0 comments on commit 2826de8

Please sign in to comment.