feat(ci): add automated cleanup of PR artifacts from JFrog#305
Open
matsaur wants to merge 1 commit into
Open
Conversation
Add a new GitHub Actions workflow that automatically deletes pull request artifacts from JFrog when the PR is merged. This includes: - Main package artifact (dev/pr/nextcloud-workspace-pr-<number>.zip) - Associated app build artifacts via JFrog AQL query The workflow triggers on pull_request.closed event when merged=true, ensuring no orphaned PR artifacts accumulate in the repository. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Matthias Sauer <sauerm@strato.de>
There was a problem hiding this comment.
Pull request overview
Adds a new GitHub Actions workflow to automatically remove merged-PR build artifacts from the snapshot JFrog Artifactory repository, covering both the main PR zip and per-app archives uploaded by CI.
Changes:
- Introduces
.github/workflows/cleanup-pr-artifacts.ymlto trigger onpull_request.closed(merged-only) and delete PR artifacts from Artifactory. - Deletes the main PR package by explicit path and app archives via
vcs.branch=<pr_number>/mergeproperty search. - Produces a step summary reporting deleted/not-found/failed outcomes.
| # Search first so we can distinguish "not found" from "found and deleted" | ||
| # from "found but delete failed". jf rt delete by itself exits 0 in all | ||
| # three cases, which makes accurate reporting impossible. | ||
| FOUND=$(jf rt search "${ARTIFACT_PATH}" | jq '.results | length') |
Comment on lines
+112
to
+114
| # jf rt search returns {"results": [{"path": "<repo>/<dir>/<file>", ...}]} | ||
| SEARCH_OUTPUT=$(jf rt search --props "vcs.branch=${VCS_BRANCH}" "${REPO}/apps/*") | ||
| ARTIFACTS=$(echo "$SEARCH_OUTPUT" | jq -r '.results[].path') |
Comment on lines
+19
to
+20
| # Only run if PR was merged | ||
| if: github.event.pull_request.merged == true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a new GitHub Actions workflow that automatically deletes pull request artifacts from JFrog Artifactory when a PR is merged. This prevents accumulation of temporary PR build artifacts and keeps the repository clean.
The workflow targets:
dev/pr/nextcloud-workspace-pr-<number>.zipbuild-external-appsjob (identified viavcs.branchproperty)Motivation
PR builds generate artifacts (both a final zip package and individual app archives) that are uploaded to JFrog for distribution or further processing. Once a PR is merged, these temporary artifacts are no longer needed and consume storage. Manual cleanup is error-prone; automated cleanup reduces housekeeping burden and keeps Artifactory tidy.
Implementation Details
Trigger:
pull_request.closedwithmerged == true— fires only when a PR is successfully merged, not on close-without-merge.Runner:
self-hosted— matches theupload-to-artifactoryjob inbuild-artifact.ymlto ensure JFrog instance is reachable.Artifact Identification:
dev/pr/nextcloud-workspace-pr-<N>.zip)vcs.branch=<N>/mergepull_requestevents,github.ref_nameis<pr_number>/mergebuild-external-appsjob records this exact value as thevcs.branchproperty on uploadError Handling:
continue-on-error: trueallows cleanup failures to not block the merge workflowTest Plan
When the next PR is merged:
vcs.branch=<PR>/mergeVerification:
ionos-productivity-ncwserver-snapshotrepositorydev/pr/nextcloud-workspace-pr-<N>.zipis gonevcs.branchare goneNotes
vcs.branch=<N>/mergebeing set during upload. If this property is not found, the search returns zero results (safe no-op). Logs will clearly show this.