Skip to content

Commit 7d84fc0

Browse files
committed
Fix handling of tag parameter
1 parent 910d47d commit 7d84fc0

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

.github/workflows/build_config_server.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
run: ./build.ps1 -Name '${{ env.IMAGE_NAME }}' -Registry '${{ env.REGISTRY }}' -Tag '${{ env.TAG }}'
4040
shell: pwsh
4141
env:
42-
TAG: ${{ github.event_name == 'pull_request' && format('{0}/{1}:pr-{2}', env.REGISTRY, env.IMAGE_NAME, github.event.number) || '' }}
42+
TAG: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || '' }}
4343

4444
- name: Login to container registry
4545
uses: docker/login-action@v3

.github/workflows/build_eureka_server.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
run: ./build.ps1 -Name '${{ env.IMAGE_NAME }}' -Registry '${{ env.REGISTRY }}' -Tag '${{ env.TAG }}'
4040
shell: pwsh
4141
env:
42-
TAG: ${{ github.event_name == 'pull_request' && format('{0}/{1}:pr-{2}', env.REGISTRY, env.IMAGE_NAME, github.event.number) || '' }}
42+
TAG: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || '' }}
4343

4444
- name: Login to container registry
4545
uses: docker/login-action@v3

.github/workflows/build_springboot_admin_server.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
run: ./build.ps1 -Name '${{ env.IMAGE_NAME }}' -Registry '${{ env.REGISTRY }}' -Tag '${{ env.TAG }}'
4040
shell: pwsh
4141
env:
42-
TAG: ${{ github.event_name == 'pull_request' && format('{0}/{1}:pr-{2}', env.REGISTRY, env.IMAGE_NAME, github.event.number) || '' }}
42+
TAG: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || '' }}
4343

4444
- name: Login to container registry
4545
uses: docker/login-action@v3

.github/workflows/build_uaa_server.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
run: ./build.ps1 -Name '${{ env.IMAGE_NAME }}' -Registry '${{ env.REGISTRY }}' -Tag '${{ env.TAG }}'
4040
shell: pwsh
4141
env:
42-
TAG: ${{ github.event_name == 'pull_request' && format('{0}/{1}:pr-{2}', env.REGISTRY, env.IMAGE_NAME, github.event.number) || '' }}
42+
TAG: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || '' }}
4343

4444
- name: Login to container registry
4545
uses: docker/login-action@v3

build.ps1

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,32 +110,32 @@ try {
110110

111111
if (!$Tag) {
112112
if ($env:GITHUB_ACTIONS -eq "true") {
113-
$Tag = "$DockerOrg/${Name}:$Version"
113+
$ImageNameWithTag = "$DockerOrg/${Name}:$Version"
114114
$Revision = Get-Content (Join-Path $ImageDirectory "metadata" "IMAGE_REVISION")
115115
if ($Revision) {
116-
$Tag += "-$Revision"
116+
$ImageNameWithTag += "-$Revision"
117117
}
118118
$AdditionalTags = "$(Get-Content (Join-Path $ImageDirectory "metadata" "ADDITIONAL_TAGS") | ForEach-Object { $_.replace("$Name","$DockerOrg/$Name") })"
119-
Write-Host "If pushed, the image will be available as: $Tag $AdditionalTags"
120119
}
121120
else {
122-
$Tag = "$DockerOrg/${Name}:dev"
121+
$ImageNameWithTag = "$DockerOrg/${Name}:dev"
123122
$AdditionalTags = ""
124-
Write-Host "The image will be locally runnable as: $Tag"
125123
}
126124
}
127125
else {
128-
Write-Host "Tag value set by script parameter: $Tag"
126+
$ImageNameWithTag = "$DockerOrg/${Name}:$Tag"
129127
$AdditionalTags = ""
130128
}
131129

130+
Write-Host "This image will be available as: $ImageNameWithTag $AdditionalTags"
131+
132132
if ($Name -eq "uaa-server") {
133133
$Dockerfile = Join-Path $ImageDirectory Dockerfile
134134
if (!(Test-Path $Dockerfile)) {
135135
throw "No Dockerfile for $Name (expected $Dockerfile)"
136136
}
137137

138-
$docker_command = "docker build -t $Tag $AdditionalTags $ImageDirectory --build-arg SERVER_VERSION=$Version"
138+
$docker_command = "docker build -t $ImageNameWithTag $AdditionalTags $ImageDirectory --build-arg SERVER_VERSION=$Version"
139139
Write-Host $docker_command
140140
Invoke-Expression $docker_command
141141
}
@@ -181,8 +181,9 @@ try {
181181
$bootVersion = Get-Content (Join-path $ImageDirectory "metadata" "SPRING_BOOT_VERSION")
182182
$serverVersion = Get-Content (Join-Path $ImageDirectory "metadata" "IMAGE_VERSION")
183183

184-
Write-Host "Building server: $Name@$serverVersion on Spring Boot $bootVersion with primary tag: $Tag"
185-
Write-Host "Using source files in: $ImageDirectory | Working directory:" $PWD
184+
Write-Host "Building server: $Name@$serverVersion on Spring Boot $bootVersion"
185+
Write-Host "Source files: $ImageDirectory"
186+
Write-Host "Working directory: $PWD"
186187

187188
# Ensure clean workspace
188189
Remove-Item -Recurse -Force $serverName -ErrorAction Ignore
@@ -235,7 +236,7 @@ try {
235236
# Build the image
236237
Push-Location $serverName
237238
try {
238-
$gradleArgs = @("bootBuildImage", "--imageName=$Tag")
239+
$gradleArgs = @("bootBuildImage", "--imageName=$ImageNameWithTag")
239240
if ($env:GITHUB_ACTIONS -eq "true") {
240241
$gradleArgs += "--no-daemon"
241242
}
@@ -247,8 +248,8 @@ try {
247248
}
248249

249250
foreach ($AdditionalTag in $AdditionalTags.Split(" ", [System.StringSplitOptions]::RemoveEmptyEntries)) {
250-
Write-Host "running 'docker tag $Tag $AdditionalTag'"
251-
docker tag $Tag $AdditionalTag
251+
Write-Host "running 'docker tag $ImageNameWithTag $AdditionalTag'"
252+
docker tag $ImageNameWithTag $AdditionalTag
252253
}
253254
}
254255
finally {

0 commit comments

Comments
 (0)