From 3eaca1e847e1e841f1ae63e290dedcc85bb14305 Mon Sep 17 00:00:00 2001 From: Tamas Pallos Date: Fri, 11 Feb 2022 11:53:48 +0200 Subject: [PATCH] Append current date to COMMIT_ID for tagging docker images --- .github/workflows/test-extract-metadata-action.yml | 3 +-- github-actions/extract-metadata/action.yml | 10 +++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-extract-metadata-action.yml b/.github/workflows/test-extract-metadata-action.yml index 013473b..d2df1c1 100644 --- a/.github/workflows/test-extract-metadata-action.yml +++ b/.github/workflows/test-extract-metadata-action.yml @@ -23,5 +23,4 @@ jobs: - name: Check that IMAGE_NAME environment variable is created and is valid run: '[[ "$IMAGE_NAME" == "hsldevcom/jore4-tools" ]]' - # (tests for BRANCH_NAME and COMMIT_ID omitted for now as they might change on each run so its a little bit tricky to test those) - + # (tests for BRANCH_NAME, CURRENT_DATE and COMMIT_ID are omitted for now as they might change on each run so its a little bit tricky to test those) diff --git a/github-actions/extract-metadata/action.yml b/github-actions/extract-metadata/action.yml index 1321746..8aaf831 100644 --- a/github-actions/extract-metadata/action.yml +++ b/github-actions/extract-metadata/action.yml @@ -28,9 +28,17 @@ runs: echo "IMAGE_NAME=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV shell: bash + - name: Extract current date + id: current-date + run: | + # fetches the current date (UTC) in "yyyymmdd" format + CURRENT_DATE=$(date +"%Y%m%d") + echo "CURRENT_DATE=${CURRENT_DATE}" >> "${GITHUB_ENV}" + shell: bash + - name: Extract commit id id: commit-id run: | # Docker tags can use only some special characters. - echo "COMMIT_ID=$(echo "${BRANCH_NAME}" | tr -C '0-9a-zA-Z._' '-')-${GITHUB_SHA}" >> $GITHUB_ENV + echo "COMMIT_ID=$(echo "${BRANCH_NAME}" | tr -C '0-9a-zA-Z._' '-')-${CURRENT_DATE}-${GITHUB_SHA}" >> $GITHUB_ENV shell: bash