chore(deps): update softprops/action-gh-release action to v2.6.1 - autoclosed #12
Workflow file for this run
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
| name: Cleanup PR Images | |
| on: | |
| pull_request: | |
| types: [closed] | |
| jobs: | |
| cleanup: | |
| runs-on: ubuntu-latest | |
| if: github.event.pull_request.merged == true | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Cleanup PR images | |
| env: | |
| GH_TOKEN: ${{ secrets.GHCR_TOKEN }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| run: | | |
| PACKAGE_NAME="custom-studios-examples/development" | |
| echo "Cleaning up images for PR #${PR_NUMBER}..." | |
| # Get all versions of the package | |
| VERSIONS=$(gh api \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| "/orgs/seqeralabs/packages/container/${PACKAGE_NAME}/versions" \ | |
| --paginate 2>/dev/null || echo "[]") | |
| # Find all versions with tags ending in -pr<PR_NUMBER> | |
| echo "$VERSIONS" | jq -r --arg pr "pr${PR_NUMBER}" ' | |
| .[] | | |
| select(.metadata.container.tags[] | endswith("-" + $pr)) | | |
| .id | |
| ' | while read -r VERSION_ID; do | |
| if [[ -n "$VERSION_ID" ]]; then | |
| TAGS=$(echo "$VERSIONS" | jq -r --arg id "$VERSION_ID" '.[] | select(.id == ($id | tonumber)) | .metadata.container.tags | join(", ")') | |
| echo "Deleting version $VERSION_ID (tags: $TAGS)..." | |
| gh api \ | |
| --method DELETE \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| "/orgs/seqeralabs/packages/container/${PACKAGE_NAME}/versions/${VERSION_ID}" \ | |
| && echo "Successfully deleted" \ | |
| || echo "Failed to delete" | |
| fi | |
| done | |
| echo "Cleanup complete for PR #${PR_NUMBER}" |