Skip to content

Commit 4b57593

Browse files
committed
chore(build): update image tagging and DockerHub integration in CI workflow
1 parent 579defa commit 4b57593

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

.github/workflows/publish-release.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ on:
55
types: [published]
66

77
env:
8-
IMAGE_NAME: ghcr.io/${{ github.repository }}
8+
IMAGE_NAME_GHCR: ghcr.io/${{ github.repository }}
9+
IMAGE_NAME_DH: docker.io/${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}
910

1011
jobs:
1112
publish-release:
@@ -32,7 +33,13 @@ jobs:
3233
username: ${{ github.actor }}
3334
password: ${{ secrets.GITHUB_TOKEN }}
3435

35-
- name: Publish artifact
36+
- name: Login to DockerHub
37+
uses: docker/login-action@v3
38+
with:
39+
username: ${{ secrets.DOCKERHUB_USERNAME }}
40+
password: ${{ secrets.DOCKERHUB_TOKEN }}
41+
42+
- name: Publish artifact and images
3643
env:
3744
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3845
GPG_KEYS: ${{ secrets.GPG_KEYS }}
@@ -41,13 +48,11 @@ jobs:
4148
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
4249
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
4350

44-
# The GITHUB_REF tag comes in the format 'refs/tags/xxx'.
45-
# So if we split on '/' and take the 3rd value, we can get the release name.
4651
run: |
4752
export GPG_TTY=$(tty) && echo "$GPG_KEYS" | gpg --fast-import --batch
4853
NEW_VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3)
49-
IMAGE=${IMAGE_NAME}:${NEW_VERSION}
50-
echo "Releasing new version ${NEW_VERSION} of $IMAGE"
54+
IMAGE_GHCR=${IMAGE_NAME_GHCR}:${NEW_VERSION}
55+
IMAGE_DH=${IMAGE_NAME_DH}:${NEW_VERSION}
56+
echo "Publishing artifacts and container images for version ${NEW_VERSION}"
5157
./gradlew -Pversion=${NEW_VERSION} publish publishToSonatype closeAndReleaseStagingRepository -Dorg.gradle.internal.publish.checksums.insecure=true --info
52-
./gradlew jib --image="${IMAGE}"
53-
58+
./gradlew jib --image="${IMAGE_GHCR}" --image="${IMAGE_DH}"

build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,13 @@ jib {
226226
}
227227
image = "gcr.io/distroless/java17-debian11"
228228
}
229+
230+
to {
231+
// Image tags are set via the CLI (--image=...) in the workflow
232+
// But can set defaults here as well (optional)
233+
tags = setOf("latest")
234+
}
235+
229236
container {
230237
ports = listOf("8080")
231238
mainClass = mainClassKt

0 commit comments

Comments
 (0)