Skip to content

Commit c697b68

Browse files
committedMay 17, 2024
GitHub Actions updates
1 parent 5d44b34 commit c697b68

File tree

3 files changed

+36
-26
lines changed

3 files changed

+36
-26
lines changed
 

‎.github/scripts/docker-tag-delete.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if [[ "${1}" == "" ]]; then
1818
exit 1
1919
else
2020
# Split image:tag
21-
IFS=$':' read IMAGE TAG <<< ${1};
21+
IFS=$':' read IMAGE TAG <<< "${1}";
2222
# Remove registry prefix from image if present
2323
IMAGE=${IMAGE#"docker.io/"}
2424
fi
@@ -42,4 +42,4 @@ output=$(curl -sI "https://hub.docker.com/v2/repositories/${IMAGE}/tags/${TAG}/"
4242
)
4343

4444
# Return and error if HTTP response code is not 204
45-
echo "${output}" | grep "HTTP/1.1 204 NO CONTENT"
45+
echo "${output}" | grep -i "HTTP/1.1 204 No Content"

‎.github/scripts/docker-tags.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ set_output() {
3535
# Print with new lines for output in build logs
3636
(IFS=$'\n'; echo "${outputArr[*]}")
3737
# Using newlines in output variables does not seem to work, so we'll use comas
38-
(IFS=$','; echo "::set-output name=tags::${outputArr[*]}")
38+
(IFS=$','; echo tags="${outputArr[*]}" | tee -a ${GITHUB_OUTPUT})
3939
}
4040

4141
# Image tags
@@ -71,4 +71,4 @@ fi
7171
# Note: imageTagArr is passed as variable name ("reference") and then expanded inside the called function
7272
# See https://stackoverflow.com/questions/16461656/how-to-pass-array-as-an-argument-to-a-function-in-bash/26443029#26443029
7373
# DockerHub tags
74-
set_output imageTagArr
74+
set_output imageTagArr

‎.github/workflows/default.yaml

+32-22
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ env:
2323
jobs:
2424
build:
2525
name: "Build: ${{ matrix.version }}/${{ matrix.arch }}"
26-
runs-on: ubuntu-20.04
26+
runs-on: ubuntu-22.04
2727

2828
strategy:
2929
fail-fast: false # Don't cancel other jobs if one fails
@@ -59,7 +59,7 @@ jobs:
5959
steps:
6060
-
6161
name: Checkout
62-
uses: actions/checkout@v2
62+
uses: actions/checkout@v4
6363
-
6464
name: Environment variables
6565
run: |
@@ -70,18 +70,18 @@ jobs:
7070
echo ARM64_HOST_SSH_CERT="$(ssh-keyscan -t rsa ${{ secrets.ARM64_HOST }} 2>/dev/null)" | tee -a ${GITHUB_ENV}
7171
-
7272
name: Set up QEMU
73-
uses: docker/setup-qemu-action@v1
73+
uses: docker/setup-qemu-action@v3
7474
-
7575
name: Set up Docker Buildx
76-
uses: docker/setup-buildx-action@v1
76+
uses: docker/setup-buildx-action@v3
7777
-
7878
name: Check Docker
7979
run: |
8080
docker version
8181
docker info
8282
-
8383
name: Login to Docker Hub
84-
uses: docker/login-action@v1
84+
uses: docker/login-action@v3
8585
with:
8686
username: ${{ secrets.DOCKERHUB_USERNAME }}
8787
password: ${{ secrets.DOCKERHUB_TOKEN }}
@@ -91,7 +91,7 @@ jobs:
9191
-
9292
# Build and cache image in the registry
9393
name: Build image
94-
uses: docker/build-push-action@v2
94+
uses: docker/build-push-action@v5
9595
with:
9696
context: ${{ env.BUILD_DIR }}
9797
file: ${{ env.BUILD_DIR }}/Dockerfile
@@ -103,13 +103,22 @@ jobs:
103103
# Push intermediate arch-specific build tag to repo
104104
tags: ${{ env.BUILD_IMAGE_TAG }}-${{ env.GIT_SHA7 }}-${{ env.ARCH }}
105105
push: ${{ github.event_name != 'pull_request' }} # Don't push for PRs
106+
# Disable automatic image attestations
107+
# With image attestations enabled, the image tag pushed to the registry is a manifest list.
108+
# That makes it impossible to stitch different platform images together in a manifest list, since you
109+
# cannot have a manifest list of manifest lists.
110+
# See https://docs.docker.com/build/attestations/attestation-storage/
111+
# TODO: Refactor to allow for image attestations
112+
provenance: false
113+
sbom: false
106114
# BUILD_IMAGE_TAG - persistent multi-arch tag, updated at the end of the build (success or failure)
107-
cache-from: type=registry,ref=${{ env.BUILD_IMAGE_TAG }}
108-
cache-to: type=inline # Write the cache metadata into the image configuration
115+
# Use registry cache with max mode to cahce all image layers in the registry
116+
cache-from: type=registry,ref=${{ env.BUILD_IMAGE_TAG }}-cache-${{ env.ARCH }}
117+
cache-to: type=registry,ref=${{ env.BUILD_IMAGE_TAG }}-cache-${{ env.ARCH }},mode=max
109118

110119
test:
111120
name: "Test: ${{ matrix.version }}/${{ matrix.arch }}"
112-
runs-on: ubuntu-20.04
121+
runs-on: ubuntu-22.04
113122
needs: build
114123

115124
strategy:
@@ -134,12 +143,10 @@ jobs:
134143
steps:
135144
-
136145
name: Setup Bats
137-
uses: mig4/setup-bats@v1
138-
with:
139-
bats-version: "1.3.0"
146+
uses: bats-core/bats-action@2.0.0
140147
-
141148
name: Checkout
142-
uses: actions/checkout@v2
149+
uses: actions/checkout@v4
143150
-
144151
name: Environment variables
145152
run: |
@@ -181,14 +188,16 @@ jobs:
181188
# Dynamic variable names cannot be used when mapping step outputs to job outputs.
182189
# Step outputs cannot be accessed directly from other jobs. Dead end.
183190
- name: Store test results
184-
uses: actions/upload-artifact@v2
191+
uses: actions/upload-artifact@v4
185192
with:
186-
name: test-results
193+
name: test-results-${{ env.GIT_SHA7 }}-${{ env.VERSION_PREFIX }}${{ env.VERSION }}-${{ env.ARCH }}
187194
path: ${{ github.workspace }}/test-results-*.txt
195+
if-no-files-found: error
196+
overwrite: true
188197

189198
push:
190199
name: "Push: ${{ matrix.version }}/multi"
191-
runs-on: ubuntu-20.04
200+
runs-on: ubuntu-22.04
192201

193202
# Wait for test to either succeed or fail
194203
needs: test
@@ -208,7 +217,7 @@ jobs:
208217
steps:
209218
-
210219
name: Checkout
211-
uses: actions/checkout@v2
220+
uses: actions/checkout@v4
212221
-
213222
name: Environment variables
214223
run: |
@@ -220,15 +229,16 @@ jobs:
220229
-
221230
# Login to Docker Hub
222231
name: Login to Docker Hub
223-
uses: docker/login-action@v1
232+
uses: docker/login-action@v3
224233
with:
225234
username: ${{ secrets.DOCKERHUB_USERNAME }}
226235
password: ${{ secrets.DOCKERHUB_TOKEN }}
227236
-
228237
name: Retrieve test results
229-
uses: actions/download-artifact@v2
238+
uses: actions/download-artifact@v4
230239
with:
231-
name: test-results
240+
pattern: test-results-${{ env.GIT_SHA7 }}-*
241+
merge-multiple: true
232242
-
233243
# Generate persistent tags (edge, stable, release)
234244
name: Docker image tags
@@ -265,5 +275,5 @@ jobs:
265275
docker manifest push ${tag}
266276
done
267277
# Clean up intermediate arch-specific image tags (DockerHub only)
268-
.github/scripts/docker-tag-delete.sh ${{ env.BUILD_IMAGE_TAG }}-${{ env.GIT_SHA7 }}-amd64
269-
.github/scripts/docker-tag-delete.sh ${{ env.BUILD_IMAGE_TAG }}-${{ env.GIT_SHA7 }}-arm64
278+
.github/scripts/docker-tag-delete.sh "${{ env.BUILD_IMAGE_TAG }}-${{ env.GIT_SHA7 }}-amd64"
279+
.github/scripts/docker-tag-delete.sh "${{ env.BUILD_IMAGE_TAG }}-${{ env.GIT_SHA7 }}-arm64"

0 commit comments

Comments
 (0)