Skip to content

Commit ddc2fdc

Browse files
committed
Set commit image expiration via Quay API
The `--annotation quay.expires-after=4w` flag does not work for multi-arch images because Quay only reads Docker image config labels, not OCI manifest annotations. Since multi-arch image indexes have no config, neither labels nor annotations reach Quay's expiration logic. Replace it with a Quay REST API call to set a 4-week expiration on the commit tag after pushing.
1 parent acf8db0 commit ddc2fdc

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

.github/workflows/container_image.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,21 @@ jobs:
2727
- name: Set up Docker Buildx
2828
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # tag=v4
2929

30-
- run: |
30+
- name: Build and push images
31+
run: |
3132
docker login -u="${{ secrets.QUAY_USERNAME }}" -p="${{ secrets.QUAY_TOKEN }}" quay.io # zizmor: ignore[secrets-outside-env]
3233
# Ensure we source identical build arguments for both builds
3334
source hack/version.sh && version::get_git_vars && version::get_build_date && \
3435
make docker-buildx IMG=${{ env.image_tag_branch }} && \
35-
make docker-buildx IMG=${{ env.image_tag_commit }} DOCKER_BUILD_ARGS="--annotation quay.expires-after=4w"
36+
make docker-buildx IMG=${{ env.image_tag_commit }}
37+
38+
- name: Set expiration on commit image
39+
env:
40+
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }} # zizmor: ignore[secrets-outside-env]
41+
run: |
42+
EXPIRATION=$(($(date -u +%s) + 2419200))
43+
curl -sf -X PUT \
44+
-H "Authorization: Bearer ${QUAY_TOKEN}" \
45+
-H "Content-Type: application/json" \
46+
-d "{\"expiration\": $EXPIRATION}" \
47+
"https://quay.io/api/v1/repository/orc/openstack-resource-controller/tag/commit-${GITHUB_SHA::7}"

0 commit comments

Comments
 (0)