Skip to content

Add workflow to use versioned images #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/docker-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Tag new images version
on:
schedule:
# Quarterly schedule, roughly aligned with JDK CPU
- cron: '0 0 30 1,4,7,10 *'
workflow_dispatch:

jobs:
tag-images:
name: Tag new images version
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # 3.3.0
- name: Login to ghcr.io
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # 2.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Tag images
run: ./build --tag
22 changes: 22 additions & 0 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,26 @@ function do_push() {
done
}

function do_tag() {
local tag token version
TAG_PREFIX=
echo "Pulling latest images"
for tag in base latest "${BASE_VARIANTS[@]}" "${VARIANTS[@]}"; do
tag="${tag,,}"
tag="$(image_name "${tag}")"
docker pull "$tag"
done
version="$(date +%y.%m)"
echo "Tagging version $version"
for tag in base latest "${BASE_VARIANTS[@]}" "${VARIANTS[@]}"; do
tag="${tag,,}"
tag="$(image_name "${tag}")"
new_tag="${tag/:/:v$version-}"
docker tag "$tag" "$new_tag"
docker push "$new_tag"
done
}

if [[ -z ${1:-} ]]; then
do_build
elif [[ ${1} = "--test" ]]; then
Expand All @@ -216,4 +236,6 @@ elif [[ ${1} = "--inner-describe" ]]; then
do_inner_describe
elif [[ ${1} = "--push" ]]; then
do_push
elif [[ ${1} = "--tag" ]]; then
do_tag
fi