Skip to content

Commit

Permalink
trying to fix docker build, so it includes git sha info.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnalogJ committed May 27, 2022
1 parent 9b90176 commit cf1bd3e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
GIT_VERSION=${{ github.ref_type == 'tag' && github.ref_name || join([github.ref_name, '#', github.sha], '') }}
GITHUB_REF_NAME=${{ env.GITHUB_REF_NAME }}
GITHUB_REF_TYPE=${{ env.GITHUB_REF_TYPE }}
GITHUB_SHA=${{ env.GITHUB_SHA }}
cache-from: type=gha
cache-to: type=gha,mode=max
omnibus:
Expand Down Expand Up @@ -154,6 +156,8 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
GIT_VERSION=${{ github.ref_type == 'tag' && github.ref_name || join([github.ref_name, '#', github.sha], '') }}
GITHUB_REF_NAME=${{ env.GITHUB_REF_NAME }}
GITHUB_REF_TYPE=${{ env.GITHUB_REF_TYPE }}
GITHUB_SHA=${{ env.GITHUB_SHA }}
cache-from: type=gha
cache-to: type=gha,mode=max
4 changes: 3 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ RUN go mod vendor && \

########
FROM node:lts-slim as frontendbuild
ARG GIT_VERSION=""
ARG GITHUB_REF_NAME=""
ARG GITHUB_REF_TYPE=""
ARG GITHUB_SHA=""
#reduce logging, disable angular-cli analytics for ci environment
ENV NPM_CONFIG_LOGLEVEL=warn NG_CLI_ANALYTICS=false

Expand Down
5 changes: 3 additions & 2 deletions docker/Dockerfile.web
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ RUN go mod vendor && \

########
FROM node:lts-slim as frontendbuild
ARG GIT_VERSION=""
ENV
ARG GITHUB_REF_NAME=""
ARG GITHUB_REF_TYPE=""
ARG GITHUB_SHA=""
#reduce logging, disable angular-cli analytics for ci environment
ENV NPM_CONFIG_LOGLEVEL=warn NG_CLI_ANALYTICS=false

Expand Down
9 changes: 7 additions & 2 deletions webapp/frontend/git.version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ const exec = promisify(child.exec);

async function createVersionsFile(filename: string) {
let versionInfo = ''
if(process.env.GIT_VERSION){
versionInfo = process.env.GIT_VERSION
if(process.env.GITHUB_SHA){
// we're in a github action

versionInfo = process.env.GITHUB_REF_NAME
if(process.env.GITHUB_REF_TYPE === 'branch'){
versionInfo += `#${process.env.GITHUB_SHA}`
}
} else {
const tag = (await exec('git describe --tags')).stdout.toString().trim();
const branch = (await exec('git rev-parse --abbrev-ref HEAD')).stdout.toString().trim();
Expand Down

0 comments on commit cf1bd3e

Please sign in to comment.