|
56 | 56 | needs: [check-permissions] |
57 | 57 | outputs: |
58 | 58 | agents: ${{ steps.get-agents.outputs.agents }} |
| 59 | + all_agents: ${{ steps.get-agents.outputs.all_agents }} |
59 | 60 | has_agents: ${{ steps.get-agents.outputs.has_agents }} |
60 | 61 | steps: |
61 | 62 | - name: Checkout repository |
|
72 | 73 | all_agents=$(find examples/tutorials -name "manifest.yaml" -exec dirname {} \; | sort) |
73 | 74 | agents_to_build=() |
74 | 75 |
|
| 76 | + # Output all agents for deprecation check |
| 77 | + all_agents_json=$(printf '%s\n' $all_agents | jq -R -s -c 'split("\n") | map(select(length > 0))') |
| 78 | + echo "all_agents=$all_agents_json" >> $GITHUB_OUTPUT |
| 79 | +
|
75 | 80 | if [ "$REBUILD_ALL" = "true" ]; then |
76 | 81 | echo "Rebuild all agents requested" |
77 | 82 | agents_to_build=($(echo "$all_agents")) |
@@ -275,3 +280,73 @@ jobs: |
275 | 280 | docker rm "$CONTAINER_NAME" > /dev/null 2>&1 || true |
276 | 281 |
|
277 | 282 | echo "✅ All validations passed for: $FULL_IMAGE" |
| 283 | +
|
| 284 | + deprecate-agents: |
| 285 | + name: "Deprecate Removed Agents" |
| 286 | + runs-on: ubuntu-latest |
| 287 | + needs: [find-agents] |
| 288 | + steps: |
| 289 | + - name: Find and delete deprecated agent packages |
| 290 | + env: |
| 291 | + GITHUB_TOKEN: ${{ secrets.PACKAGE_TOKEN }} |
| 292 | + run: | |
| 293 | + set -e |
| 294 | +
|
| 295 | + echo "🔍 Agents in repo (from find-agents):" |
| 296 | + # Convert JSON array of paths to package names |
| 297 | + # e.g., "examples/tutorials/00_sync/000_hello_acp" -> "00_sync-000_hello_acp" |
| 298 | + REPO_AGENTS=$(echo '${{ needs.find-agents.outputs.all_agents }}' | jq -r '.[]' | \ |
| 299 | + sed 's|examples/tutorials/||' | \ |
| 300 | + sed 's|/|-|g') |
| 301 | + echo "$REPO_AGENTS" |
| 302 | +
|
| 303 | + echo "" |
| 304 | + echo "🔍 Fetching packages from GitHub Container Registry..." |
| 305 | + PACKAGES=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \ |
| 306 | + -H "Accept: application/vnd.github+json" \ |
| 307 | + "https://api.github.com/orgs/scaleapi/packages?package_type=container&per_page=100") |
| 308 | +
|
| 309 | + # Check for API errors |
| 310 | + if echo "$PACKAGES" | jq -e '.message' > /dev/null 2>&1; then |
| 311 | + echo "❌ GitHub API error:" |
| 312 | + echo "$PACKAGES" | jq '.' |
| 313 | + exit 1 |
| 314 | + fi |
| 315 | +
|
| 316 | + # Filter for tutorial-agents from this repo |
| 317 | + TUTORIAL_PACKAGES=$(echo "$PACKAGES" | \ |
| 318 | + jq -r '.[] | select(.repository != null and .repository.name == "scale-agentex-python" and (.name | contains("tutorial-agents"))) | .name') |
| 319 | +
|
| 320 | + echo "Tutorial packages in registry:" |
| 321 | + echo "$TUTORIAL_PACKAGES" |
| 322 | +
|
| 323 | + echo "" |
| 324 | + echo "🔍 Checking for deprecated packages..." |
| 325 | + while IFS= read -r package_name; do |
| 326 | + [ -z "$package_name" ] && continue |
| 327 | +
|
| 328 | + # Extract agent name: scale-agentex-python/tutorial-agents/00_sync-000_hello_acp -> 00_sync-000_hello_acp |
| 329 | + agent_name=$(echo "$package_name" | sed 's|.*/tutorial-agents/||') |
| 330 | +
|
| 331 | + if ! echo "$REPO_AGENTS" | grep -q "^${agent_name}$"; then |
| 332 | + echo "🗑️ $agent_name - NOT in repo, deleting..." |
| 333 | + # URL encode the package name (replace / with %2F) |
| 334 | + encoded_package=$(echo "$package_name" | sed 's|/|%2F|g') |
| 335 | + response=$(curl -s -w "\n%{http_code}" -X DELETE \ |
| 336 | + -H "Authorization: Bearer $GITHUB_TOKEN" \ |
| 337 | + -H "Accept: application/vnd.github+json" \ |
| 338 | + "https://api.github.com/orgs/scaleapi/packages/container/${encoded_package}") |
| 339 | +
|
| 340 | + http_code=$(echo "$response" | tail -n1) |
| 341 | + body=$(echo "$response" | sed '$d') |
| 342 | +
|
| 343 | + if [ "$http_code" = "204" ] || [ "$http_code" = "200" ]; then |
| 344 | + echo " ✅ Deleted: $package_name" |
| 345 | + else |
| 346 | + echo " ⚠️ Failed to delete $package_name (HTTP $http_code): $body" |
| 347 | + fi |
| 348 | + fi |
| 349 | + done <<< "$TUTORIAL_PACKAGES" |
| 350 | +
|
| 351 | + echo "" |
| 352 | + echo "✅ Deprecation check complete" |
0 commit comments