trying to fix docker build, so it includes git sha info.

This commit is contained in:
Jason Kulatunga
2022-05-27 00:13:34 -07:00
parent 9b901766e3
commit cf1bd3ea6b
4 changed files with 19 additions and 7 deletions
+6 -2
View File
@@ -106,7 +106,9 @@ jobs:
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
build-args: | 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-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
omnibus: omnibus:
@@ -154,6 +156,8 @@ jobs:
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
build-args: | 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-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
+3 -1
View File
@@ -12,7 +12,9 @@ RUN go mod vendor && \
######## ########
FROM node:lts-slim as frontendbuild 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 #reduce logging, disable angular-cli analytics for ci environment
ENV NPM_CONFIG_LOGLEVEL=warn NG_CLI_ANALYTICS=false ENV NPM_CONFIG_LOGLEVEL=warn NG_CLI_ANALYTICS=false
+3 -2
View File
@@ -10,8 +10,9 @@ RUN go mod vendor && \
######## ########
FROM node:lts-slim as frontendbuild FROM node:lts-slim as frontendbuild
ARG GIT_VERSION="" ARG GITHUB_REF_NAME=""
ENV ARG GITHUB_REF_TYPE=""
ARG GITHUB_SHA=""
#reduce logging, disable angular-cli analytics for ci environment #reduce logging, disable angular-cli analytics for ci environment
ENV NPM_CONFIG_LOGLEVEL=warn NG_CLI_ANALYTICS=false ENV NPM_CONFIG_LOGLEVEL=warn NG_CLI_ANALYTICS=false
+7 -2
View File
@@ -6,8 +6,13 @@ const exec = promisify(child.exec);
async function createVersionsFile(filename: string) { async function createVersionsFile(filename: string) {
let versionInfo = '' let versionInfo = ''
if(process.env.GIT_VERSION){ if(process.env.GITHUB_SHA){
versionInfo = process.env.GIT_VERSION // 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 { } else {
const tag = (await exec('git describe --tags')).stdout.toString().trim(); const tag = (await exec('git describe --tags')).stdout.toString().trim();
const branch = (await exec('git rev-parse --abbrev-ref HEAD')).stdout.toString().trim(); const branch = (await exec('git rev-parse --abbrev-ref HEAD')).stdout.toString().trim();