Merge branch 'vogler:main' into main
This commit is contained in:
commit
53c6b41579
5 changed files with 80 additions and 7 deletions
14
.github/workflows/docker.yml
vendored
14
.github/workflows/docker.yml
vendored
|
|
@ -20,6 +20,11 @@ jobs:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Set environment variables
|
||||||
|
run: |
|
||||||
|
echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
|
||||||
|
echo "NOW=$(date -R)" >> $GITHUB_ENV # date -Iseconds; date +'%Y-%m-%dT%H:%M:%S'
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-qemu-action@v2
|
||||||
|
|
@ -29,6 +34,7 @@ jobs:
|
||||||
-
|
-
|
||||||
name: Login to Docker Hub
|
name: Login to Docker Hub
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
|
# if: ${{ secrets.DOCKERHUB_USERNAME && secrets.DOCKERHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
@ -44,8 +50,14 @@ jobs:
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64,linux/arm64 # ,linux/arm/v7
|
|
||||||
push: true
|
push: true
|
||||||
|
build-args: |
|
||||||
|
COMMIT=${{ github.sha }}
|
||||||
|
BRANCH=${{ env.BRANCH }}
|
||||||
|
NOW=${{ env.NOW }}
|
||||||
|
platforms: linux/amd64,linux/arm64 # ,linux/arm/v7
|
||||||
tags: |
|
tags: |
|
||||||
voglerr/free-games-claimer:latest
|
voglerr/free-games-claimer:latest
|
||||||
ghcr.io/vogler/free-games-claimer:latest
|
ghcr.io/vogler/free-games-claimer:latest
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
|
|
||||||
|
|
@ -60,12 +60,19 @@ COPY . .
|
||||||
RUN dos2unix *.sh && chmod +x *.sh
|
RUN dos2unix *.sh && chmod +x *.sh
|
||||||
COPY docker-entrypoint.sh /usr/local/bin/
|
COPY docker-entrypoint.sh /usr/local/bin/
|
||||||
|
|
||||||
|
ARG COMMIT=""
|
||||||
|
ARG BRANCH=""
|
||||||
|
ARG NOW=""
|
||||||
|
ENV COMMIT=${COMMIT}
|
||||||
|
ENV BRANCH=${BRANCH}
|
||||||
|
ENV NOW=${NOW}
|
||||||
|
|
||||||
LABEL org.opencontainers.image.title="free-games-claimer" \
|
LABEL org.opencontainers.image.title="free-games-claimer" \
|
||||||
org.opencontainers.image.name="free-games-claimer" \
|
org.opencontainers.image.name="free-games-claimer" \
|
||||||
org.opencontainers.image.description="Automatically claims free games on the Epic Games Store, Amazon Prime Gaming and GOG" \
|
org.opencontainers.image.description="Automatically claims free games on the Epic Games Store, Amazon Prime Gaming and GOG" \
|
||||||
org.opencontainers.image.url="https://github.com/vogler/free-games-claimer" \
|
org.opencontainers.image.url="https://github.com/vogler/free-games-claimer" \
|
||||||
org.opencontainers.image.source="https://github.com/vogler/free-games-claimer" \
|
org.opencontainers.image.source="https://github.com/vogler/free-games-claimer" \
|
||||||
org.opencontainers.image.revision=${COMMIT_SHA} \
|
org.opencontainers.image.revision=${COMMIT} \
|
||||||
org.opencontainers.image.ref.name=${BRANCH} \
|
org.opencontainers.image.ref.name=${BRANCH} \
|
||||||
org.opencontainers.image.base.name="ubuntu:jammy" \
|
org.opencontainers.image.base.name="ubuntu:jammy" \
|
||||||
org.opencontainers.image.version="latest"
|
org.opencontainers.image.version="latest"
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
set -eo pipefail # exit on error, error on any fail in pipe (not just last cmd); add -x to print each cmd; see gist bash_strict_mode.md
|
set -eo pipefail # exit on error, error on any fail in pipe (not just last cmd); add -x to print each cmd; see gist bash_strict_mode.md
|
||||||
|
|
||||||
|
echo "Version: https://github.com/vogler/free-games-claimer/tree/${COMMIT}"
|
||||||
|
[ ! -z $BRANCH ] && [ $BRANCH != "main" ] && echo "Branch: ${BRANCH}"
|
||||||
|
echo "Build: $NOW"
|
||||||
|
|
||||||
# Remove chromium profile lock.
|
# Remove chromium profile lock.
|
||||||
# When running in docker and then killing it, on the next run chromium displayed a dialog to unlock the profile which made the script time out.
|
# When running in docker and then killing it, on the next run chromium displayed a dialog to unlock the profile which made the script time out.
|
||||||
# Maybe due to changed hostname of container or due to how the docker container kills playwright - didn't check.
|
# Maybe due to changed hostname of container or due to how the docker container kills playwright - didn't check.
|
||||||
|
|
|
||||||
10
util.js
10
util.js
|
|
@ -108,11 +108,11 @@ export const notify = (html) => new Promise((resolve, reject) => {
|
||||||
const title = cfg.notify_title ? `-t ${cfg.notify_title}` : '';
|
const title = cfg.notify_title ? `-t ${cfg.notify_title}` : '';
|
||||||
exec(`apprise ${cfg.notify} -i html '${title}' -b '${html}'`, (error, stdout, stderr) => {
|
exec(`apprise ${cfg.notify} -i html '${title}' -b '${html}'`, (error, stdout, stderr) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.log(`error: ${error.message}`);
|
console.log(`error: ${error.message}`);
|
||||||
if (error.message.includes('command not found')) {
|
if (error.message.includes('command not found')) {
|
||||||
console.info('Run `pip install apprise`. See https://github.com/vogler/free-games-claimer#notifications');
|
console.info('Run `pip install apprise`. See https://github.com/vogler/free-games-claimer#notifications');
|
||||||
}
|
}
|
||||||
return resolve();
|
return resolve();
|
||||||
}
|
}
|
||||||
if (stderr) console.error(`stderr: ${stderr}`);
|
if (stderr) console.error(`stderr: ${stderr}`);
|
||||||
if (stdout) console.log(`stdout: ${stdout}`);
|
if (stdout) console.log(`stdout: ${stdout}`);
|
||||||
|
|
|
||||||
50
version.js
Normal file
50
version.js
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
// check if running the latest version
|
||||||
|
|
||||||
|
import {log} from 'console';
|
||||||
|
import { readFileSync } from 'fs';
|
||||||
|
import { exec } from 'child_process';
|
||||||
|
|
||||||
|
const execp = (cmd) => new Promise((resolve, reject) => {
|
||||||
|
exec(cmd, (error, stdout, stderr) => {
|
||||||
|
if (stderr) console.error(`stderr: ${stderr}`);
|
||||||
|
// if (stdout) console.log(`stdout: ${stdout}`);
|
||||||
|
if (error) {
|
||||||
|
console.log(`error: ${error.message}`);
|
||||||
|
if (error.message.includes('command not found')) {
|
||||||
|
console.info('Install git to check for updates!');
|
||||||
|
}
|
||||||
|
return reject();
|
||||||
|
}
|
||||||
|
resolve(stdout.trim());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const git_main = () => readFileSync('.git/refs/heads/main').toString().trim();
|
||||||
|
|
||||||
|
let sha, date;
|
||||||
|
// if (existsSync('/.dockerenv')) { // did not work
|
||||||
|
if (process.env.NOVNC_PORT) {
|
||||||
|
log('Running inside Docker.');
|
||||||
|
['COMMIT', 'BRANCH', 'NOW'].forEach(v => log(` ${v}:`, process.env[v]));
|
||||||
|
sha = process.env.COMMIT;
|
||||||
|
date = process.env.NOW;
|
||||||
|
} else {
|
||||||
|
log('Not running inside Docker.');
|
||||||
|
sha = await execp('git rev-parse HEAD');
|
||||||
|
date = await execp('git show -s --format=%cD'); // same as format as `date -R` (RFC2822)
|
||||||
|
// date = await execp('git show -s --format=%ch'); // %ch is same as --date=human (short/relative)
|
||||||
|
}
|
||||||
|
|
||||||
|
const gh = await (await fetch('https://api.github.com/repos/vogler/free-games-claimer/commits/main', {
|
||||||
|
// headers: { accept: 'application/vnd.github.VERSION.sha' }
|
||||||
|
})).json();
|
||||||
|
// log(gh);
|
||||||
|
|
||||||
|
log('Local commit:', sha, new Date(date));
|
||||||
|
log('Online commit:', gh.sha, new Date(gh.commit.committer.date));
|
||||||
|
|
||||||
|
if (sha == gh.sha) {
|
||||||
|
log('Running the latest version!')
|
||||||
|
} else {
|
||||||
|
log('Not running the latest version!')
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue