Skip to content

Commit 53182c9

Browse files
committed
refactor: use date.short-sha for IMAGE_VERSION, checkout latest tag on schedule
1 parent c43bf47 commit 53182c9

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

.github/workflows/build.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ env:
1616
IMAGE_DESC: "${{ github.event.repository.name }}"
1717
IMAGE_NAME: "${{ github.event.repository.name }}" # output image name, usually same as repo name
1818
IMAGE_REGISTRY: "ghcr.io/${{ github.repository_owner }}" # do not edit
19-
IMAGE_VERSION: "sha-${{ github.sha }}"
2019
DEFAULT_TAG: "latest"
2120

2221
concurrency:
@@ -52,9 +51,13 @@ jobs:
5251
else
5352
echo "IMAGE_NAME=${IMAGE_NAME,,}-${{ matrix.variant }}" >> ${GITHUB_ENV}
5453
fi
54+
# Set IMAGE_VERSION as date.short-sha
55+
echo "IMAGE_VERSION=$(date +%Y%m%d).${GITHUB_SHA::7}" >> ${GITHUB_ENV}
5556
5657
- name: Checkout
5758
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v5
59+
with:
60+
ref: ${{ github.event_name == 'schedule' && 'latest' || github.ref }}
5861

5962
- name: Get ISO 8601 timestamp for OCI image labels
6063
id: iso8601
@@ -143,7 +146,7 @@ jobs:
143146
with:
144147
ref: localhost/${{ env.IMAGE_NAME }}:${{ env.DEFAULT_TAG }}
145148
version: ${{ env.IMAGE_VERSION }}
146-
revision: ${{ github.sha }}
149+
revision: ${{ env.IMAGE_VERSION }}
147150

148151
- name: Login to GitHub Container Registry
149152
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3

0 commit comments

Comments
 (0)