Skip to content

Commit

Permalink
Dual-push images to Docker Hub and GHCR
Browse files Browse the repository at this point in the history
  • Loading branch information
chadlwilson committed Jul 4, 2023
1 parent e815322 commit a9975a9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to Docker Hub Container Registry
uses: docker/login-action@v2
with:
registry: docker.io
username: ${{ env.DOCKER_HUB_ID }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: ASDF setup
uses: asdf-vm/actions/setup@v2

Expand Down Expand Up @@ -82,4 +89,4 @@ jobs:
env:
JAVA_HOME: ${{ env.JAVA_HOME }}
with:
arguments: jib -x check
arguments: jibGitHubContainerRegistry jibDockerHub -x check
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,5 @@ Current release process looks like
# Patch version (e.g 0.6.0 -> 0.6.1)
./gradlew -Preckon.stage=final -Preckon.scope=patch reckonTagPush
```
2. The tag push will trigger a build on [GitHub Actions](https://github.com/ThoughtWorks-SEA/recce/actions) and push to GHCR.
2. The tag push will trigger a build on [GitHub Actions](https://github.com/ThoughtWorks-SEA/recce/actions) and push to both GHCR and Docker Hub.
3. Create a new release on Github via https://github.com/ThoughtWorks-SEA/recce/releases linked to the tag
17 changes: 15 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ jib {
.setNormalVersion(fullVersion.normalVersion)
.setPreReleaseVersion(fullVersion.preReleaseVersion.split('.')[0])
.build()
image = "ghcr.io/$githubRepoOwner/$containerRepoName"
tags = setOf(tagVersion.toString(), "latest")
}
container {
Expand All @@ -297,9 +296,23 @@ val checkJibDependencies = tasks.register("checkJibDependencies") {
}

// Jib task pushes an image. Only do so after running all checks
tasks.jib.configure {
tasks.register<com.google.cloud.tools.jib.gradle.BuildImageTask>("jibGitHubContainerRegistry") {
dependsOn(checkJibDependencies)
dependsOn(tasks.check)
setJibExtension(project.extensions.getByName("jib") as com.google.cloud.tools.jib.gradle.JibExtension)
doFirst {
jib?.to?.image = "ghcr.io/$githubRepoOwner/$containerRepoName"
}
}

// Jib task pushes an image. Only do so after running all checks
tasks.register<com.google.cloud.tools.jib.gradle.BuildImageTask>("jibDockerHub") {
dependsOn(checkJibDependencies)
dependsOn(tasks.check)
setJibExtension(project.extensions.getByName("jib") as com.google.cloud.tools.jib.gradle.JibExtension)
doFirst {
jib?.to?.image = "docker.io/recceteam/$containerRepoName"
}
}

// use different naming when building locally, to avoid confusion
Expand Down

0 comments on commit a9975a9

Please sign in to comment.