Skip to content

Commit

Permalink
Append current date to COMMIT_ID for tagging docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
pallost committed Feb 11, 2022
1 parent 1e11f2f commit 3eaca1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/test-extract-metadata-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
10 changes: 9 additions & 1 deletion github-actions/extract-metadata/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 3eaca1e

Please sign in to comment.