From 7fb9956c106e82e79572368009830b1eaec479d9 Mon Sep 17 00:00:00 2001 From: Glenn de Haan Date: Mon, 7 Oct 2024 10:44:02 +0200 Subject: [PATCH] Implemented Git version tag into docker build and GitHub actions. Implemented Release Notes button. Updated Documentation button to directly navigate to the README.md --- .github/workflows/publish.yml | 4 ++++ Dockerfile | 2 ++ modules/info.js | 4 ++-- modules/variables.js | 3 ++- server.js | 2 ++ template/partials/navigation.ejs | 8 +++++++- 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 397a2d5..6a7adab 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -32,6 +32,8 @@ jobs: platforms: linux/amd64,linux/arm64 push: true tags: glenndehaan/unifi-voucher-site:${{ github.ref_name }} + build-args: | + GIT_TAG=${{ github.ref_name }} - name: Build and push (latest) if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v5 @@ -40,3 +42,5 @@ jobs: platforms: linux/amd64,linux/arm64 push: true tags: glenndehaan/unifi-voucher-site:latest + build-args: | + GIT_TAG=master diff --git a/Dockerfile b/Dockerfile index 7545d2a..ea1470a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -115,3 +115,5 @@ COPY . . # Set build # RUN echo -n `date '+%Y.%m.%d.%H.%M'` > /etc/unifi_voucher_site_build +ARG GIT_TAG +ENV GIT_TAG=$GIT_TAG diff --git a/modules/info.js b/modules/info.js index 1eb076a..fefb88a 100644 --- a/modules/info.js +++ b/modules/info.js @@ -39,9 +39,9 @@ module.exports = () => { * Output build version */ if(fs.existsSync('/etc/unifi_voucher_site_build')) { - log.info(`[Version] ${fs.readFileSync('/etc/unifi_voucher_site_build', 'utf-8')}`); + log.info(`[Version] Git: ${variables.gitTag}, Build: ${fs.readFileSync('/etc/unifi_voucher_site_build', 'utf-8')}`); } else { - log.info(`[Version] **DEVELOPMENT**`); + log.info(`[Version] Git: ${variables.gitTag}, Build: **DEVELOPMENT**`); } /** diff --git a/modules/variables.js b/modules/variables.js index 384d31b..a67b528 100644 --- a/modules/variables.js +++ b/modules/variables.js @@ -35,5 +35,6 @@ module.exports = { smtpSecure: config('smtp_secure') || process.env.SMTP_SECURE || false, smtpUsername: config('smtp_username') || process.env.SMTP_USERNAME || '', smtpPassword: config('smtp_password') || process.env.SMTP_PASSWORD || '', - logLevel: config('log_level') || process.env.LOG_LEVEL || 'info' + logLevel: config('log_level') || process.env.LOG_LEVEL || 'info', + gitTag: process.env.GIT_TAG || 'master' }; diff --git a/server.js b/server.js index 8046b67..1b0ac80 100644 --- a/server.js +++ b/server.js @@ -366,6 +366,7 @@ if(variables.serviceWeb) { res.render('voucher', { baseUrl: req.headers['x-ingress-path'] ? req.headers['x-ingress-path'] : '', + gitTag: variables.gitTag, user: user, userIcon: req.oidc ? crypto.createHash('sha256').update(user.email).digest('hex') : '', authDisabled: variables.authDisabled, @@ -412,6 +413,7 @@ if(variables.serviceWeb) { res.render('status', { baseUrl: req.headers['x-ingress-path'] ? req.headers['x-ingress-path'] : '', + gitTag: variables.gitTag, user: user, userIcon: req.oidc ? crypto.createHash('sha256').update(user.email).digest('hex') : '', authDisabled: variables.authDisabled, diff --git a/template/partials/navigation.ejs b/template/partials/navigation.ejs index 6b575fc..c48c699 100644 --- a/template/partials/navigation.ejs +++ b/template/partials/navigation.ejs @@ -44,12 +44,18 @@ Feature Status - + Documentation + + + + + Release Notes + <% if(!authDisabled) { %>