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
33 changes: 23 additions & 10 deletions .github/workflows/clean-ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,28 @@ 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 servicecontrol-audit servicecontrol-monitoring servicecontrol-ravendb
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: |
cutoff=$(date -u -d "2 weeks ago" +"%Y-%m-%dT%H:%M:%SZ")
images=("servicecontrol" "servicecontrol-audit" "servicecontrol-monitoring" "servicecontrol-ravendb")

for image in "${images[@]}"; do
echo "Processing image: $image"
version_ids=$(gh api --paginate "/orgs/particular/packages/container/${image}/versions" | \
jq -r --arg cutoff "$cutoff" \
'.[] | select(.updated_at < $cutoff) | select(.metadata.container.tags | (length == 0 or any(.[]; test("^pr-") or test("-alpha\\.")))) | .id')

if [ -n "$version_ids" ]; then
echo "$version_ids" | while read -r version_id; do
echo "Deleting version $version_id of $image"
gh api --method DELETE "/orgs/particular/packages/container/${image}/versions/${version_id}"
done
else
echo "No versions to delete for $image"
fi
done
59 changes: 24 additions & 35 deletions .github/workflows/push-container-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,39 +49,28 @@ jobs:
Invoke-Expression $cmd
Write-Output "::endgroup::"
}
- name: Update Docker Hub Description - ServiceControl
- name: Update Docker Hub Descriptions
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
readme-filepath: ./src/ServiceControl/Container-README.md
short-description: Gather status, performance and monitoring data for multiple endpoints from a single location.
- name: Update Docker Hub Description - Audit
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-audit
readme-filepath: ./src/ServiceControl.Audit/Container-README.md
short-description: Provide valuable information about the message flow through a system.
- name: Update Docker Hub Description - Monitoring
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-monitoring
readme-filepath: ./src/ServiceControl.Monitoring/Container-README.md
short-description: Track the health of a distributed system.
- name: Update Docker Hub Description - RavenDB
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-ravendb
readme-filepath: ./src/ServiceControl.RavenDB/Container-README.md
short-description: The default storage for ServiceControl instances.
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
run: |
$ErrorActionPreference = 'Stop'
$loginBody = @{ username = $env:DOCKERHUB_USERNAME; password = $env:DOCKERHUB_TOKEN } | ConvertTo-Json
$loginResponse = Invoke-RestMethod -Uri "https://hub.docker.com/v2/users/login" -Method Post -ContentType "application/json" -Body $loginBody
$token = $loginResponse.token
$headers = @{ Authorization = "Bearer $token" }

$repos = @(
@{ name = "servicecontrol"; readme = "./src/ServiceControl/Container-README.md"; description = "Gather status, performance and monitoring data for multiple endpoints from a single location." },
@{ name = "servicecontrol-audit"; readme = "./src/ServiceControl.Audit/Container-README.md"; description = "Provide valuable information about the message flow through a system." },
@{ name = "servicecontrol-monitoring"; readme = "./src/ServiceControl.Monitoring/Container-README.md"; description = "Track the health of a distributed system." },
@{ name = "servicecontrol-ravendb"; readme = "./src/ServiceControl.RavenDB/Container-README.md"; description = "The default storage for ServiceControl instances." }
)

foreach ($repo in $repos) {
$readmeContent = Get-Content -Raw $repo.readme
$updateBody = @{ description = $repo.description; full_description = $readmeContent } | ConvertTo-Json -Depth 5
Invoke-RestMethod -Uri "https://hub.docker.com/v2/repositories/particular/$($repo.name)/" -Method Patch -ContentType "application/json" -Headers $headers -Body $updateBody
Write-Output "Updated description for particular/$($repo.name)"
}
Loading