deps: bump nvidia/cuda from 12.1-devel-ubuntu22.04 to 13.2.0-devel-ubuntu22.04 #40
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Agent Complete — Destroy + Drain | |
| on: | |
| pull_request: | |
| types: [opened, closed] | |
| jobs: | |
| cleanup-and-drain: | |
| if: startsWith(github.head_ref, 'feat/issue-') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| issues: write | |
| actions: write | |
| steps: | |
| - name: Extract issue number | |
| id: issue | |
| run: echo "number=$(echo '${{ github.head_ref }}' | sed 's/[^0-9]//g')" >> $GITHUB_OUTPUT | |
| - name: Delete ephemeral service | |
| env: | |
| RAILWAY_API_TOKEN: ${{ secrets.RAILWAY_API_TOKEN }} | |
| RAILWAY_PROJECT_ID: ${{ secrets.RAILWAY_PROJECT_ID }} | |
| ISSUE: ${{ steps.issue.outputs.number }} | |
| run: | | |
| set -e | |
| echo "🗑️ Looking for ephemeral service agent-${ISSUE}..." | |
| # Find service by name | |
| SERVICES=$(curl -s -X POST "https://railway.com/graphql/v2" \ | |
| -H "Authorization: Bearer ${RAILWAY_API_TOKEN}" \ | |
| -H "Content-Type: application/json" \ | |
| -d "{ | |
| \"query\": \"query(\$id: String!) { project(id: \$id) { services { edges { node { id name } } } } }\", | |
| \"variables\": { \"id\": \"${RAILWAY_PROJECT_ID}\" } | |
| }") | |
| SERVICE_ID=$(echo "$SERVICES" | jq -r ".data.project.services.edges[].node | select(.name == \"agent-${ISSUE}\") | .id // empty") | |
| if [ -n "$SERVICE_ID" ]; then | |
| echo "Found service $SERVICE_ID, deleting..." | |
| curl -s -X POST "https://railway.com/graphql/v2" \ | |
| -H "Authorization: Bearer ${RAILWAY_API_TOKEN}" \ | |
| -H "Content-Type: application/json" \ | |
| -d "{ | |
| \"query\": \"mutation(\$id: String!) { serviceDelete(id: \$id) }\", | |
| \"variables\": { \"id\": \"${SERVICE_ID}\" } | |
| }" > /dev/null | |
| echo "✅ Service agent-${ISSUE} destroyed" | |
| else | |
| echo "ℹ️ No ephemeral service found for issue #${ISSUE} (pool mode or already cleaned)" | |
| fi | |
| - name: Close issue on PR merge | |
| if: github.event.pull_request.merged == true | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| ISSUE: ${{ steps.issue.outputs.number }} | |
| run: | | |
| gh issue close "${ISSUE}" \ | |
| --repo "${{ github.repository }}" \ | |
| --comment "✅ PR merged, ephemeral service destroyed. Issue complete." \ | |
| 2>/dev/null || echo "Issue #${ISSUE} already closed" | |
| - name: Drain queue — spawn next | |
| if: github.event.pull_request.merged == true || github.event.action == 'opened' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Find next queued issue | |
| NEXT=$(gh issue list -R ${{ github.repository }} \ | |
| --label "agent:queued" \ | |
| --state open \ | |
| --sort created \ | |
| --json number \ | |
| -q '.[0].number') | |
| if [ -n "$NEXT" ]; then | |
| echo "🔄 Draining queue: spawning agent for issue #${NEXT}" | |
| gh issue edit "$NEXT" -R ${{ github.repository }} --remove-label "agent:queued" | |
| gh workflow run agent-ephemeral.yml -R ${{ github.repository }} -f issue_number="$NEXT" | |
| echo "✅ Triggered spawn for #${NEXT}" | |
| else | |
| echo "ℹ️ No queued issues to drain" | |
| fi |