Skip to content

Commit

Permalink
Read commit SHA from file. Fixes #378
Browse files Browse the repository at this point in the history
  • Loading branch information
claabs committed Feb 15, 2024
1 parent a9756df commit 3a1c950
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ RUN ln -s /usr/local/bin/docker-entrypoint.sh /
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

LABEL org.opencontainers.image.title="epicgames-freegames-node" \
org.opencontainers.image.url="https://github.com/claabs/epicgames-freegames-node" \
org.opencontainers.image.description="Automatically redeem free games promotions on the Epic Games store" \
Expand Down
9 changes: 8 additions & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import axios from 'axios';
import { readFileSync } from 'fs-extra';
import { config } from './common/config';
import L from './common/logger';

const PROJECT_NAME = 'epicgames-freegames-node';
const { COMMIT_SHA, BRANCH, DISTRO } = process.env;
const { BRANCH, DISTRO } = process.env;
let { COMMIT_SHA } = process.env;
try {
COMMIT_SHA = readFileSync('./commit-sha.txt', { encoding: 'utf-8' }).trim();
} catch (error) {
L.debug('Fallback to environment variable commit SHA');
}

export async function checkForUpdate(): Promise<void> {
L.info({ COMMIT_SHA, BRANCH, DISTRO }, `Started ${PROJECT_NAME}`);
Expand Down

0 comments on commit 3a1c950

Please sign in to comment.