Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
32 changes: 22 additions & 10 deletions .github/workflows/clean-ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,27 @@ jobs:
clean:
name: Delete unused containers
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Clean up images
uses: snok/container-retention-policy@v3.0.1
with:
image-names: servicecontrol-masstransit-connector
image-tags: pr-*, *-alpha.*
tag-selection: both
cut-off: 2w
timestamp-to-use: updated_at
account: particular
token: ${{ secrets.GITHUB_TOKEN }}
dry-run: false
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Requires GNU date (available on ubuntu-latest runners)
CUTOFF=$(date -u -d '2 weeks ago' +%Y-%m-%dT%H:%M:%SZ)
echo "Cutoff date: $CUTOFF"

# Matches tags with pr-* prefix or *-alpha.* pattern (e.g. 1.0.0-alpha.1)
gh api --paginate "/orgs/particular/packages/container/servicecontrol-masstransit-connector/versions" \
| jq -r --arg cutoff "$CUTOFF" '
.[]
| select(
(.metadata.container.tags | map(test("^pr-") or test("-alpha\\.")) | any) and
(.updated_at < $cutoff)
)
| .id' \
| while IFS= read -r version_id; do
echo "Deleting version: $version_id"
gh api --method DELETE "/orgs/particular/packages/container/servicecontrol-masstransit-connector/versions/$version_id"
done
33 changes: 26 additions & 7 deletions .github/workflows/push-container-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,29 @@ jobs:
Invoke-Expression $cmd
- name: Update Docker Hub Description
if: ${{ steps.validate.outputs.latest == 'true' }}
uses: peter-evans/dockerhub-description@v5.0.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: particular/servicecontrol-masstransit-connector
readme-filepath: ./Container-README.md
short-description: An extension to ServiceControl that adds support for processing MassTransit failures.
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
run: |
if (-not (Test-Path './Container-README.md')) {
throw "Container-README.md not found"
}

$loginBody = @{ username = $env:DOCKERHUB_USERNAME; password = $env:DOCKERHUB_TOKEN } | ConvertTo-Json
$loginResponse = Invoke-RestMethod -Uri 'https://hub.docker.com/v2/users/login' -Method Post -Body $loginBody -ContentType 'application/json'
if (-not $loginResponse.token) {
throw "Docker Hub authentication failed: no token returned"
}
$token = $loginResponse.token

$readme = Get-Content -Path './Container-README.md' -Raw
$updateBody = @{
full_description = $readme
description = 'An extension to ServiceControl that adds support for processing MassTransit failures.'
} | ConvertTo-Json -Depth 3

Invoke-RestMethod -Uri 'https://hub.docker.com/v2/repositories/particular/servicecontrol-masstransit-connector/' `
-Method Patch `
-Headers @{ Authorization = "Bearer $token" } `
-Body $updateBody `
-ContentType 'application/json'
Loading