From 34c9c5b34b02a9e298f6a1b23d13a8619e61662c Mon Sep 17 00:00:00 2001 From: Thomas Burkhalter Date: Thu, 29 Feb 2024 12:42:09 +0100 Subject: [PATCH] Fix build info --- .github/workflows/reusable-build.yaml | 6 +++--- Dockerfile | 15 +++++++++------ config/application.rb | 4 ++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.github/workflows/reusable-build.yaml b/.github/workflows/reusable-build.yaml index 48888a61..f574860c 100644 --- a/.github/workflows/reusable-build.yaml +++ b/.github/workflows/reusable-build.yaml @@ -43,9 +43,9 @@ jobs: with: file: Dockerfile build-args: | - BUILD_REPO=$GITHUB_REPOSITORY - BUILD_REF=$GITHUB_REF_NAME - BUILD_COMMIT=$GITHUB_SHA + GITHUB_REF_NAME=$GITHUB_REF_NAME + GITHUB_REPOSITORY=$GITHUB_REPOSITORY + GITHUB_SHA=$GITHUB_SHA target: app tags: | ${{ inputs.registry }}/ptime/${{ inputs.project_name }}:latest diff --git a/Dockerfile b/Dockerfile index 79a0c6cd..45832db0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,9 +32,9 @@ ARG RAILS_DB_ADAPTER="nulldb" ARG GITHUB_SHA ARG GITHUB_REPOSITORY ARG GITHUB_REF_NAME -ARG BUILD_COMMIT="$GITHUB_SHA" -ARG BUILD_REPO="$GITHUB_REPOSITORY" -ARG BUILD_REF="$GITHUB_REF_NAME" +ARG BUILD_COMMIT +ARG BUILD_REPO +ARG BUILD_REF # # Gitlab specific # ARG CI_COMMIT_SHA @@ -158,6 +158,9 @@ ARG RAILS_ENV # data persisted in the image ARG PS1 ARG TZ +ARG GITHUB_SHA +ARG GITHUB_REPOSITORY +ARG GITHUB_REF_NAME ARG BUILD_COMMIT ARG BUILD_REPO ARG BUILD_REF @@ -167,9 +170,9 @@ ARG SKIP_MEMCACHE_CHECK ENV PS1="${PS1}" \ TZ="${TZ}" \ - BUILD_REPO="${BUILD_REPO}" \ - BUILD_REF="${BUILD_REF}" \ - BUILD_COMMIT="${BUILD_COMMIT}" \ + BUILD_REPO="${BUILD_REPO:-${GITHUB_REPOSITORY}}" \ + BUILD_REF="${BUILD_REF:-${GITHUB_REF_NAME}}" \ + BUILD_COMMIT="${BUILD_COMMIT:-${GITHUB_SHA}}" \ RAILS_ENV="${RAILS_ENV}" \ RACK_ENV="${RACK_ENV}" diff --git a/config/application.rb b/config/application.rb index 019b8712..5520ee00 100644 --- a/config/application.rb +++ b/config/application.rb @@ -98,9 +98,9 @@ def self.build_version end def self.commit_hash(short: false) - return unless File.exist?(Rails.root.join('BUILD_INFO').to_s) + return unless ENV['BUILD_COMMIT'] - commit = File.open(Rails.root.join('BUILD_INFO').to_s).first.chomp + commit = ENV['BUILD_COMMIT'].first.chomp return commit.first(7) if short commit