Skip to content

Commit d4bddd0

Browse files
committed
ci: Use a matrix for publishing docker images
1 parent 6e7d93e commit d4bddd0

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

.github/workflows/publish.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ jobs:
116116
permissions:
117117
contents: read
118118
packages: write
119+
strategy:
120+
matrix:
121+
include:
122+
- platform: linux/amd64
123+
cache-ref: buildcache-amd64
124+
- platform: linux/arm64
125+
cache-ref: buildcache-arm64
119126
steps:
120127
- name: Check out the repo
121128
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
@@ -137,21 +144,28 @@ jobs:
137144
uses: ./.github/actions/docker-build
138145
with:
139146
push: "true"
140-
platforms: linux/amd64,linux/arm64
147+
platforms: ${{ matrix.platform }}
141148
dockerfile: ./Dockerfile
142149
context: .
143150
image-name: elementsinteractive/twyn
144-
cache-from: type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache-amd64,ref=ghcr.io/elementsinteractive/twyn:buildcache-arm64
151+
cache-from: type=registry,ref=ghcr.io/elementsinteractive/twyn:${{ matrix.cache-ref }}
145152

146153
- name: Delete old cache entries
147154
env:
148155
GH_TOKEN: ${{ github.token }}
149156
run: |
150-
# Get all versions of the container package
151-
versions=$(gh api "orgs/elementsinteractive/packages/container/twyn/versions" --paginate)
152-
153-
# Extract version IDs that do NOT have any buildcache-* tags (buildcache-amd64, buildcache-arm64, etc.)
154-
ids_to_delete=$(echo "$versions" | jq -r '.[] | select(.metadata.container.tags | map(test("^buildcache-")) | any | not) | .id')
157+
# Get all versions (paginate + slurp into one array)
158+
versions=$(gh api "orgs/elementsinteractive/packages/container/twyn/versions" --paginate | jq -s 'add')
159+
160+
# Pattern for the current cache ref (GitHub Actions expression expands before script runs)
161+
cache_ref="${{ matrix.cache-ref }}"
162+
163+
# Extract version IDs that do NOT have the cache_ref tag
164+
ids_to_delete=$(echo "$versions" | jq -r --arg pattern "$cache_ref" '
165+
.[]
166+
| select(.metadata.container.tags | map(test($pattern)) | any | not)
167+
| .id
168+
')
155169
156170
# Delete them
157171
for id in $ids_to_delete; do

0 commit comments

Comments
 (0)