From d946c587b20fccc8bf7f5866200025d012294ec6 Mon Sep 17 00:00:00 2001 From: Nazmi Altun Date: Tue, 6 Dec 2022 23:04:46 +0800 Subject: [PATCH] feat(docker build): Pass docker meta creation date as build arg Docker meta action exposes created date which can be passed to service image as a build arg --- .gflows/libs/steps.lib.yml | 1 + github-sample/workflows/build-publish.yml | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/.gflows/libs/steps.lib.yml b/.gflows/libs/steps.lib.yml index 3cedf63..9b5e7e2 100644 --- a/.gflows/libs/steps.lib.yml +++ b/.gflows/libs/steps.lib.yml @@ -114,6 +114,7 @@ with: #@ end #@ build_args.append("COMMIT_SHA=${{ github.sha }}") #@ if build_versioned_image: + #@ build_args.append("BUILD_DATETIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}") #@ build_args.append("APP_VERSION=${{ needs.version.outputs.app_version }}") #@ build_args.append("FILE_VERSION=${{ needs.version.outputs.file_version }}") #@ build_args.append("INFORMATIONAL_VERSION=${{ needs.version.outputs.information_version }}") diff --git a/github-sample/workflows/build-publish.yml b/github-sample/workflows/build-publish.yml index 3f98507..7cc35dd 100644 --- a/github-sample/workflows/build-publish.yml +++ b/github-sample/workflows/build-publish.yml @@ -111,6 +111,7 @@ jobs: type=registry,ref=ghcr.io/covergo/auth-nuget-cache:${{ needs.version.outputs.issue_id_slug }} build-args: |- COMMIT_SHA=${{ github.sha }} + BUILD_DATETIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} APP_VERSION=${{ needs.version.outputs.app_version }} FILE_VERSION=${{ needs.version.outputs.file_version }} INFORMATIONAL_VERSION=${{ needs.version.outputs.information_version }} @@ -182,6 +183,7 @@ jobs: cache-to: type=registry,ref=ghcr.io/covergo/auth-nuget-default-cache:${{ needs.version.outputs.issue_id_slug }},mode=max build-args: |- COMMIT_SHA=${{ github.sha }} + BUILD_DATETIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} APP_VERSION=${{ needs.version.outputs.app_version }} FILE_VERSION=${{ needs.version.outputs.file_version }} INFORMATIONAL_VERSION=${{ needs.version.outputs.information_version }} @@ -266,6 +268,7 @@ jobs: build-args: |- NOW="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" COMMIT_SHA=${{ github.sha }} + BUILD_DATETIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} APP_VERSION=${{ needs.version.outputs.app_version }} FILE_VERSION=${{ needs.version.outputs.file_version }} INFORMATIONAL_VERSION=${{ needs.version.outputs.information_version }} @@ -314,6 +317,7 @@ jobs: target: build-predeployment build-args: |- COMMIT_SHA=${{ github.sha }} + BUILD_DATETIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} APP_VERSION=${{ needs.version.outputs.app_version }} FILE_VERSION=${{ needs.version.outputs.file_version }} INFORMATIONAL_VERSION=${{ needs.version.outputs.information_version }}