diff --git a/Dockerfile b/Dockerfile index 81530d8..2881577 100644 --- a/Dockerfile +++ b/Dockerfile @@ -63,7 +63,7 @@ ARG COMMIT_SHA="" \ BRANCH="" # Put COMMIT_SHA in a file, since Docker managers like Portainer will not use updated ENVs -RUN echo $COMMIT_SHA > commit-sha.txt +RUN echo $COMMIT_SHA > commit-sha.txt && echo $BRANCH > branch.txt LABEL org.opencontainers.image.title="epicgames-freegames-node" \ org.opencontainers.image.url="https://github.com/claabs/epicgames-freegames-node" \ diff --git a/src/version.ts b/src/version.ts index c56ca4f..f99e7cc 100644 --- a/src/version.ts +++ b/src/version.ts @@ -4,13 +4,18 @@ import { config } from './common/config/index.js'; import L from './common/logger.js'; const PROJECT_NAME = 'epicgames-freegames-node'; -const { BRANCH, DISTRO } = process.env; -let { COMMIT_SHA } = process.env; +const { DISTRO } = process.env; +let { COMMIT_SHA, BRANCH } = process.env; try { COMMIT_SHA = readFileSync('./commit-sha.txt', { encoding: 'utf-8' }).trim(); } catch (error) { L.debug('Fallback to environment variable commit SHA'); } +try { + BRANCH = readFileSync('./branch.txt', { encoding: 'utf-8' }).trim(); +} catch (error) { + L.debug('Fallback to environment variable branch'); +} export async function checkForUpdate(): Promise { L.info({ COMMIT_SHA, BRANCH, DISTRO }, `Started ${PROJECT_NAME}`);