Skip to content

Commit a945e77

Browse files
Antigravity Agentclaude
andcommitted
fix(cloud): cleanup workflow — add --repo flag, skip service deletion
Bug #24: gh issue close needs --repo flag (not a git repo in Actions) Bug #25: service deletion unnecessary with pooled services Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 89a312a commit a945e77

1 file changed

Lines changed: 7 additions & 30 deletions

File tree

.github/workflows/agent-cleanup.yml

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,15 @@ jobs:
1212
steps:
1313
- name: Extract issue number
1414
id: issue
15-
run: echo "number=$(echo '${{ github.event.pull_request.head.ref }}' | grep -oP '\d+')" >> $GITHUB_OUTPUT
16-
17-
- name: Kill agent container via Railway API
18-
env:
19-
RAILWAY_API_TOKEN: ${{ secrets.RAILWAY_API_TOKEN }}
20-
RAILWAY_PROJECT_ID: ${{ secrets.RAILWAY_PROJECT_ID }}
21-
run: |
22-
ISSUE="${{ steps.issue.outputs.number }}"
23-
SERVICE_NAME="agent-${ISSUE}"
24-
echo "🗑️ Cleaning up ${SERVICE_NAME}..."
25-
26-
# Find service by name
27-
SERVICES=$(curl -s -X POST "https://backboard.railway.com/graphql/v2" \
28-
-H "Authorization: Bearer ${RAILWAY_API_TOKEN}" \
29-
-H "Content-Type: application/json" \
30-
-d "{\"query\":\"query { project(id: \\\"${RAILWAY_PROJECT_ID}\\\") { services { edges { node { id name } } } } }\"}")
31-
32-
SERVICE_ID=$(echo "$SERVICES" | jq -r ".data.project.services.edges[].node | select(.name == \"${SERVICE_NAME}\") | .id" 2>/dev/null || true)
33-
34-
if [ -n "$SERVICE_ID" ]; then
35-
curl -s -X POST "https://backboard.railway.com/graphql/v2" \
36-
-H "Authorization: Bearer ${RAILWAY_API_TOKEN}" \
37-
-H "Content-Type: application/json" \
38-
-d "{\"query\":\"mutation { serviceDelete(id: \\\"${SERVICE_ID}\\\") }\"}" > /dev/null 2>&1
39-
echo "✅ Service ${SERVICE_NAME} deleted"
40-
else
41-
echo "⚠️ Service ${SERVICE_NAME} not found (may already be deleted)"
42-
fi
15+
run: echo "number=$(echo '${{ github.event.pull_request.head.ref }}' | sed 's/[^0-9]//g')" >> $GITHUB_OUTPUT
4316

4417
- name: Close issue
4518
env:
4619
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4720
run: |
48-
gh issue close ${{ steps.issue.outputs.number }} \
49-
--comment "🏠 Agent returned home. Container destroyed. PR merged."
21+
ISSUE="${{ steps.issue.outputs.number }}"
22+
echo "🏠 Closing issue #${ISSUE} after PR merge..."
23+
gh issue close "${ISSUE}" \
24+
--repo "${{ github.repository }}" \
25+
--comment "🏠 Agent returned home. PR merged. Services are pooled (not destroyed)." \
26+
2>/dev/null || echo "⚠️ Issue #${ISSUE} already closed or not found"

0 commit comments

Comments
 (0)