|
7 | 7 | pull_request: |
8 | 8 | branches: [main] |
9 | 9 | merge_group: |
| 10 | + delete: # Trigger cleanup when branches are deleted |
10 | 11 |
|
11 | 12 | env: |
12 | 13 | REGISTRY: ghcr.io |
@@ -128,7 +129,57 @@ jobs: |
128 | 129 | echo "$TAGS" | while IFS= read -r tag; do |
129 | 130 | [ -z "$tag" ] && continue |
130 | 131 | echo "Creating manifest for: $tag" |
131 | | - docker buildx imagetools create -t "$tag" \ |
| 132 | + docker buildx imagetools create \ |
| 133 | + --annotation "index:org.opencontainers.image.description=ML-guided qPCR primer design with off-target minimization" \ |
| 134 | + --annotation "index:org.opencontainers.image.source=https://github.com/broadinstitute/qprimer_designer" \ |
| 135 | + --annotation "index:org.opencontainers.image.licenses=MIT" \ |
| 136 | + -t "$tag" \ |
132 | 137 | "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${SUFFIX}-amd64" \ |
133 | 138 | "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${SUFFIX}-arm64" |
134 | 139 | done |
| 140 | +
|
| 141 | + cleanup-untagged: |
| 142 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 143 | + needs: [create-manifest] |
| 144 | + runs-on: ubuntu-latest |
| 145 | + permissions: |
| 146 | + packages: write |
| 147 | + steps: |
| 148 | + - uses: actions/delete-package-versions@v5 |
| 149 | + with: |
| 150 | + package-name: qprimer_designer |
| 151 | + package-type: container |
| 152 | + min-versions-to-keep: 5 |
| 153 | + delete-only-untagged-versions: true |
| 154 | + |
| 155 | + cleanup-branch-images: |
| 156 | + if: github.event_name == 'delete' && github.event.ref_type == 'branch' |
| 157 | + runs-on: ubuntu-latest |
| 158 | + permissions: |
| 159 | + packages: write |
| 160 | + steps: |
| 161 | + - name: Delete branch images from ghcr.io |
| 162 | + env: |
| 163 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 164 | + run: | |
| 165 | + # Sanitize branch name (same logic as build jobs) |
| 166 | + SUFFIX=$(echo '${{ github.event.ref }}' | tr '/' '-') |
| 167 | +
|
| 168 | + for arch in amd64 arm64; do |
| 169 | + TAG="${SUFFIX}-${arch}" |
| 170 | + echo "Looking for tag: $TAG" |
| 171 | +
|
| 172 | + # Get version ID for this tag |
| 173 | + VERSION_ID=$(gh api \ |
| 174 | + "orgs/${{ github.repository_owner }}/packages/container/qprimer_designer/versions" \ |
| 175 | + --jq ".[] | select(.metadata.container.tags | contains([\"$TAG\"])) | .id" \ |
| 176 | + 2>/dev/null || true) |
| 177 | +
|
| 178 | + if [ -n "$VERSION_ID" ]; then |
| 179 | + gh api --method DELETE \ |
| 180 | + "orgs/${{ github.repository_owner }}/packages/container/qprimer_designer/versions/$VERSION_ID" |
| 181 | + echo "Deleted version $VERSION_ID (tag: $TAG)" |
| 182 | + else |
| 183 | + echo "Tag $TAG not found, skipping" |
| 184 | + fi |
| 185 | + done |
0 commit comments