summaryrefslogtreecommitdiff
path: root/docker-bake.hcl
diff options
context:
space:
mode:
authorCrazyMax <crazy-max@users.noreply.github.com>2022-12-26 18:46:26 +0100
committerCrazyMax <crazy-max@users.noreply.github.com>2023-01-01 18:03:03 +0100
commit27ba1766e79c0ac7ae3f43ba7dc8d622ca6cdf42 (patch)
treefdfd22c54d0a9dfb8e1d92748ade0df30a9cef0f /docker-bake.hcl
parent0b3af098e12d6960407d6f667055d1ef88a77afb (diff)
downloaddocker-27ba1766e79c0ac7ae3f43ba7dc8d622ca6cdf42.tar.gz
ci: use GITHUB_REF and GITHUB_SHA to set version and commit
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Diffstat (limited to 'docker-bake.hcl')
-rw-r--r--docker-bake.hcl16
1 files changed, 14 insertions, 2 deletions
diff --git a/docker-bake.hcl b/docker-bake.hcl
index d0c7cf29d4..46b110e45f 100644
--- a/docker-bake.hcl
+++ b/docker-bake.hcl
@@ -47,6 +47,18 @@ variable "PACKAGER_NAME" {
default = ""
}
+# GITHUB_REF is the actual ref that triggers the workflow and used as version
+# when tag is pushed: https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
+variable "GITHUB_REF" {
+ default = ""
+}
+
+# GITHUB_SHA is the commit SHA that triggered the workflow and used as commit.
+# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
+variable "GITHUB_SHA" {
+ default = ""
+}
+
# Defines the output folder
variable "DESTDIR" {
default = ""
@@ -64,8 +76,8 @@ target "_common" {
DOCKER_STATIC = DOCKER_STATIC
DOCKER_LDFLAGS = DOCKER_LDFLAGS
DOCKER_BUILDTAGS = DOCKER_BUILDTAGS
- DOCKER_GITCOMMIT = DOCKER_GITCOMMIT
- VERSION = VERSION
+ DOCKER_GITCOMMIT = DOCKER_GITCOMMIT != "" ? DOCKER_GITCOMMIT : GITHUB_SHA
+ VERSION = VERSION != "" ? VERSION : GITHUB_REF
PLATFORM = PLATFORM
PRODUCT = PRODUCT
DEFAULT_PRODUCT_LICENSE = DEFAULT_PRODUCT_LICENSE