Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ci): clean up test images after closing PRs #609

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
- name: Build scorecard image for test
id: build-scorecard
run: |
CUSTOM_SCORECARD_IMG=ghcr.io/${{ github.repository_owner }}/cryostat-operator-scorecard:ci-$GITHUB_SHA \
CUSTOM_SCORECARD_IMG=ghcr.io/${{ github.repository_owner }}/cryostat-operator-scorecard:pr-${{ github.event.number }}-$GITHUB_SHA \
PLATFORMS=linux/amd64 \
MANIFEST_PUSH=false \
make scorecard-build
Expand All @@ -102,10 +102,10 @@ jobs:
- name: Build operator image for test
id: build-operator
run: |
OPERATOR_IMG=ghcr.io/${{ github.repository_owner }}/cryostat-operator:ci-$GITHUB_SHA \
OPERATOR_IMG=ghcr.io/${{ github.repository_owner }}/cryostat-operator:pr-${{ github.event.number }}-$GITHUB_SHA \
SKIP_TESTS=true \
make oci-build
echo "tag=ci-$GITHUB_SHA" >> $GITHUB_OUTPUT
echo "tag=pr-${{ github.event.number }}-$GITHUB_SHA" >> $GITHUB_OUTPUT
- name: Push operator image to ghcr.io for test
id: push-operator-to-ghcr
uses: redhat-actions/push-to-registry@v2
Expand All @@ -120,9 +120,9 @@ jobs:
run: |
yq -i '.spec.template.spec.imagePullSecrets = [{"name": "registry-key"}]' config/manager/manager.yaml
OPERATOR_IMG=${{ steps.push-operator-to-ghcr.outputs.registry-path }} \
BUNDLE_IMG=ghcr.io/${{ github.repository_owner }}/cryostat-operator-bundle:ci-$GITHUB_SHA \
make bundle bundle-build
echo "tag=ci-$GITHUB_SHA" >> $GITHUB_OUTPUT
BUNDLE_IMG=ghcr.io/${{ github.repository_owner }}/cryostat-operator-bundle:pr-${{ github.event.number }}-$GITHUB_SHA \
make bundle bundle-build
echo "tag=pr-${{ github.event.number }}-$GITHUB_SHA" >> $GITHUB_OUTPUT
- name: Push bundle image to ghcr.io for test
id: push-bundle-to-ghcr
uses: redhat-actions/push-to-registry@v2
Expand Down Expand Up @@ -182,7 +182,7 @@ jobs:
echo "tags=$IMG_TAG latest" >> $GITHUB_OUTPUT
else
echo "tags=$IMG_TAG" >> $GITHUB_OUTPUT
fi
fi
- name: Push to quay.io
id: push-to-quay
uses: redhat-actions/push-to-registry@v2
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/image-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Clean up PR-scoped test images

on:
pull_request_target:
types:
- closed

jobs:
delete-images:
name: Delete PR-scoped test images
tthvo marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
if: github.repository_owner == 'cryostatio'
strategy:
matrix:
image: [cryostat-operator, cryostat-operator-bundle, cryostat-operator-scorecard]
steps:
- name: Delete Docker images
tthvo marked this conversation as resolved.
Show resolved Hide resolved
uses: r26d/ghcr-delete-image-action@v1.2.2
with:
owner: ${{ github.repository_owner }}
name: ${{ matrix.image }}
token: ${{ secrets.GHCR_PR_TOKEN }}
ignore-missing-package: true
tag-regex: pr-${{ github.event.number }}-.*
tagged-keep-latest: 0
Loading