Skip to content

Commit

Permalink
[Build] Fix docker tag naming for number/merge type "branches"
Browse files Browse the repository at this point in the history
  • Loading branch information
Schaka committed Oct 5, 2024
1 parent a3c83ab commit 53d9637
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ jobs:
distribution: 'temurin'
cache: 'gradle'

- name: Export branch name
uses: mad9000/actions-find-and-replace-string@5
id: branch_name
with:
source: ${{ github.ref_name }}
find: '/'
replace: '-'

- name: Log in to Docker Hub to pull images without rate limit
uses: docker/login-action@v3
with:
Expand Down Expand Up @@ -105,9 +113,9 @@ jobs:
with:
push: true
tags: |
ghcr.io/schaka/janitorr:native-${{ github.ref_name }}
ghcr.io/schaka/janitorr:native-${{ steps.branch_name.outputs.value }}
${{ (startsWith(github.ref, 'refs/tags/v') && 'ghcr.io/schaka/janitorr:native-stable') || '' }}
sources: |
ghcr.io/schaka/janitorr:native-amd64-${{ github.ref_name }}
ghcr.io/schaka/janitorr:native-arm64-${{ github.ref_name }}
ghcr.io/schaka/janitorr:native-amd64-${{ steps.branch_name.outputs.value }}
ghcr.io/schaka/janitorr:native-arm64-${{ steps.branch_name.outputs.value }}
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ configure<VersioningExtension> {
extra {
val build = getBuild()
val versioning: VersioningExtension = extensions.getByName<VersioningExtension>("versioning")
val branch = versioning.info.branch
val branch = versioning.info.branch.replace("/", "-")
val shortCommit = versioning.info.commit.take(8)

project.extra["build.date-time"] = build.buildDateAndTime
Expand All @@ -110,7 +110,7 @@ extra {
project.extra["build.user"] = build.userName()

val containerImageName = "schaka/${project.name}"
val containerImageTags = mutableSetOf(shortCommit, branch).map { it.replace("/", "-") }.toMutableSet()
val containerImageTags = mutableSetOf(shortCommit, branch)
if (branch.startsWith("v")) {
containerImageTags.add("stable")
}
Expand Down

0 comments on commit 53d9637

Please sign in to comment.