Skip to content

Commit 94bda39

Browse files
Copilotafprtclr
andauthored
Replace peter-evans/dockerhub-description and snok/container-retention-policy with first-party alternatives
Agent-Logs-Url: https://github.com/Particular/ServiceControl/sessions/c22057b7-5131-4ced-a4a0-d38810e8f2ae Co-authored-by: afprtclr <208591451+afprtclr@users.noreply.github.com>
1 parent 9fa1373 commit 94bda39

2 files changed

Lines changed: 47 additions & 45 deletions

File tree

.github/workflows/clean-ghcr.yml

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,28 @@ jobs:
77
clean:
88
name: Delete unused containers
99
runs-on: ubuntu-latest
10+
permissions:
11+
packages: write
1012
steps:
1113
- name: Clean up images
12-
uses: snok/container-retention-policy@v3.0.1
13-
with:
14-
image-names: servicecontrol servicecontrol-audit servicecontrol-monitoring servicecontrol-ravendb
15-
image-tags: pr-*, *-alpha.*
16-
tag-selection: both
17-
cut-off: 2w
18-
timestamp-to-use: updated_at
19-
account: particular
20-
token: ${{ secrets.GITHUB_TOKEN }}
21-
dry-run: false
14+
env:
15+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
run: |
17+
cutoff=$(date -u -d "2 weeks ago" +"%Y-%m-%dT%H:%M:%SZ")
18+
images=("servicecontrol" "servicecontrol-audit" "servicecontrol-monitoring" "servicecontrol-ravendb")
19+
20+
for image in "${images[@]}"; do
21+
echo "Processing image: $image"
22+
version_ids=$(gh api --paginate "/orgs/particular/packages/container/${image}/versions" | \
23+
jq -r --arg cutoff "$cutoff" \
24+
'.[] | select(.updated_at < $cutoff) | select(.metadata.container.tags | (length == 0 or any(.[]; test("^pr-") or test("-alpha\\.")))) | .id')
25+
26+
if [ -n "$version_ids" ]; then
27+
echo "$version_ids" | while read -r version_id; do
28+
echo "Deleting version $version_id of $image"
29+
gh api --method DELETE "/orgs/particular/packages/container/${image}/versions/${version_id}"
30+
done
31+
else
32+
echo "No versions to delete for $image"
33+
fi
34+
done

.github/workflows/push-container-images.yml

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -49,39 +49,28 @@ jobs:
4949
Invoke-Expression $cmd
5050
Write-Output "::endgroup::"
5151
}
52-
- name: Update Docker Hub Description - ServiceControl
52+
- name: Update Docker Hub Descriptions
5353
if: ${{ steps.validate.outputs.latest == 'true' }}
54-
uses: peter-evans/dockerhub-description@v5.0.0
55-
with:
56-
username: ${{ secrets.DOCKERHUB_USERNAME }}
57-
password: ${{ secrets.DOCKERHUB_TOKEN }}
58-
repository: particular/servicecontrol
59-
readme-filepath: ./src/ServiceControl/Container-README.md
60-
short-description: Gather status, performance and monitoring data for multiple endpoints from a single location.
61-
- name: Update Docker Hub Description - Audit
62-
if: ${{ steps.validate.outputs.latest == 'true' }}
63-
uses: peter-evans/dockerhub-description@v5.0.0
64-
with:
65-
username: ${{ secrets.DOCKERHUB_USERNAME }}
66-
password: ${{ secrets.DOCKERHUB_TOKEN }}
67-
repository: particular/servicecontrol-audit
68-
readme-filepath: ./src/ServiceControl.Audit/Container-README.md
69-
short-description: Provide valuable information about the message flow through a system.
70-
- name: Update Docker Hub Description - Monitoring
71-
if: ${{ steps.validate.outputs.latest == 'true' }}
72-
uses: peter-evans/dockerhub-description@v5.0.0
73-
with:
74-
username: ${{ secrets.DOCKERHUB_USERNAME }}
75-
password: ${{ secrets.DOCKERHUB_TOKEN }}
76-
repository: particular/servicecontrol-monitoring
77-
readme-filepath: ./src/ServiceControl.Monitoring/Container-README.md
78-
short-description: Track the health of a distributed system.
79-
- name: Update Docker Hub Description - RavenDB
80-
if: ${{ steps.validate.outputs.latest == 'true' }}
81-
uses: peter-evans/dockerhub-description@v5.0.0
82-
with:
83-
username: ${{ secrets.DOCKERHUB_USERNAME }}
84-
password: ${{ secrets.DOCKERHUB_TOKEN }}
85-
repository: particular/servicecontrol-ravendb
86-
readme-filepath: ./src/ServiceControl.RavenDB/Container-README.md
87-
short-description: The default storage for ServiceControl instances.
54+
env:
55+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
56+
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
57+
run: |
58+
$ErrorActionPreference = 'Stop'
59+
$loginBody = @{ username = $env:DOCKERHUB_USERNAME; password = $env:DOCKERHUB_TOKEN } | ConvertTo-Json
60+
$loginResponse = Invoke-RestMethod -Uri "https://hub.docker.com/v2/users/login" -Method Post -ContentType "application/json" -Body $loginBody
61+
$token = $loginResponse.token
62+
$headers = @{ Authorization = "Bearer $token" }
63+
64+
$repos = @(
65+
@{ name = "servicecontrol"; readme = "./src/ServiceControl/Container-README.md"; description = "Gather status, performance and monitoring data for multiple endpoints from a single location." },
66+
@{ name = "servicecontrol-audit"; readme = "./src/ServiceControl.Audit/Container-README.md"; description = "Provide valuable information about the message flow through a system." },
67+
@{ name = "servicecontrol-monitoring"; readme = "./src/ServiceControl.Monitoring/Container-README.md"; description = "Track the health of a distributed system." },
68+
@{ name = "servicecontrol-ravendb"; readme = "./src/ServiceControl.RavenDB/Container-README.md"; description = "The default storage for ServiceControl instances." }
69+
)
70+
71+
foreach ($repo in $repos) {
72+
$readmeContent = Get-Content -Raw $repo.readme
73+
$updateBody = @{ description = $repo.description; full_description = $readmeContent } | ConvertTo-Json -Depth 5
74+
Invoke-RestMethod -Uri "https://hub.docker.com/v2/repositories/particular/$($repo.name)/" -Method Patch -ContentType "application/json" -Headers $headers -Body $updateBody
75+
Write-Output "Updated description for particular/$($repo.name)"
76+
}

0 commit comments

Comments
 (0)