Skip to content

Commit

Permalink
Don't use ENV for branch value
Browse files Browse the repository at this point in the history
  • Loading branch information
claabs committed Sep 8, 2024
1 parent f72eb88 commit 85e8a5d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
9 changes: 7 additions & 2 deletions src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
L.info({ COMMIT_SHA, BRANCH, DISTRO }, `Started ${PROJECT_NAME}`);
Expand Down

0 comments on commit 85e8a5d

Please sign in to comment.