Skip to content

Commit af63005

Browse files
authored
Add workflow to use versioned images (#72)
1 parent c12c420 commit af63005

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

.github/workflows/docker-tag.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Tag new images version
2+
on:
3+
schedule:
4+
# Quarterly schedule, roughly aligned with JDK CPU
5+
- cron: '0 0 30 1,4,7,10 *'
6+
workflow_dispatch:
7+
8+
jobs:
9+
tag-images:
10+
name: Tag new images version
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # 3.3.0
18+
- name: Login to ghcr.io
19+
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # 2.1.0
20+
with:
21+
registry: ghcr.io
22+
username: ${{ github.actor }}
23+
password: ${{ secrets.GITHUB_TOKEN }}
24+
- name: Tag images
25+
run: ./build --tag

build

+22
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,26 @@ function do_push() {
203203
done
204204
}
205205

206+
function do_tag() {
207+
local tag token version
208+
TAG_PREFIX=
209+
echo "Pulling latest images"
210+
for tag in base latest "${BASE_VARIANTS[@]}" "${VARIANTS[@]}"; do
211+
tag="${tag,,}"
212+
tag="$(image_name "${tag}")"
213+
docker pull "$tag"
214+
done
215+
version="$(date +%y.%m)"
216+
echo "Tagging version $version"
217+
for tag in base latest "${BASE_VARIANTS[@]}" "${VARIANTS[@]}"; do
218+
tag="${tag,,}"
219+
tag="$(image_name "${tag}")"
220+
new_tag="${tag/:/:v$version-}"
221+
docker tag "$tag" "$new_tag"
222+
docker push "$new_tag"
223+
done
224+
}
225+
206226
if [[ -z ${1:-} ]]; then
207227
do_build
208228
elif [[ ${1} = "--test" ]]; then
@@ -216,4 +236,6 @@ elif [[ ${1} = "--inner-describe" ]]; then
216236
do_inner_describe
217237
elif [[ ${1} = "--push" ]]; then
218238
do_push
239+
elif [[ ${1} = "--tag" ]]; then
240+
do_tag
219241
fi

0 commit comments

Comments
 (0)