Skip to content

Commit 79a3e81

Browse files
authored
ghcr: Fix local built image name in tests (#2686)
* ghcr: Fix local built image name in tests * Push to registry when tagged * Fix push and experiment * Remove debug
1 parent e8cb680 commit 79a3e81

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

.github/workflows/ghcr.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ jobs:
109109
# Load the Docker image and capture the output
110110
output=$(docker load -i /tmp/sandbox_image_amd64.tar)
111111
112-
# Extract the image name from the output
113-
image_name=$(echo "$output" | grep -oP 'Loaded image: \K.*')
112+
# Extract the first image name from the output
113+
image_name=$(echo "$output" | grep -oP 'Loaded image: \K.*' | head -n 1)
114114
115115
# Print the full name of the image
116116
echo "Loaded Docker image: $image_name"
@@ -161,8 +161,8 @@ jobs:
161161
# Load the Docker image and capture the output
162162
output=$(docker load -i /tmp/sandbox_image_amd64.tar)
163163
164-
# Extract the image name from the output
165-
image_name=$(echo "$output" | grep -oP 'Loaded image: \K.*')
164+
# Extract the first image name from the output
165+
image_name=$(echo "$output" | grep -oP 'Loaded image: \K.*' | head -n 1)
166166
167167
# Print the full name of the image
168168
echo "Loaded Docker image: $image_name"
@@ -178,7 +178,7 @@ jobs:
178178
runs-on: ubuntu-latest
179179
# don't push if integration tests or sandbox tests fail
180180
needs: [ghcr_build, integration-tests-on-linux, test-for-sandbox]
181-
if: github.ref == 'refs/heads/main'
181+
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
182182

183183
env:
184184
tags: ${{ needs.ghcr_build.outputs.tags }}
@@ -212,7 +212,8 @@ jobs:
212212
- name: Load images and push to registry
213213
run: |
214214
mv /tmp/${{ matrix.platform }}/${{ matrix.image }}_image_${{ matrix.platform }}.tar .
215-
loaded_image=$(docker load -i ${{ matrix.image }}_image_${{ matrix.platform }}.tar | grep "Loaded image:" | awk '{print $3}')
215+
loaded_image=$(docker load -i ${{ matrix.image }}_image_${{ matrix.platform }}.tar | grep "Loaded image:" | head -n 1 | awk '{print $3}')
216+
echo "loaded image = $loaded_image"
216217
tags=$(echo ${tags} | tr ' ' '\n')
217218
image_name=$(echo "ghcr.io/${{ github.repository_owner }}/${{ matrix.image }}" | tr '[:upper:]' '[:lower:]')
218219
echo "image name = $image_name"
@@ -225,7 +226,7 @@ jobs:
225226
create_manifest:
226227
runs-on: ubuntu-latest
227228
needs: [ghcr_build, ghcr_push]
228-
if: github.ref == 'refs/heads/main'
229+
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
229230

230231
env:
231232
tags: ${{ needs.ghcr_build.outputs.tags }}

0 commit comments

Comments
 (0)