|
@@ -37,11 +37,25 @@ jobs:
|
|
|
- name: delete droplets
|
|
|
if: success() || failure()
|
|
|
run: |
|
|
|
- sleep 15m
|
|
|
- curl -X DELETE \
|
|
|
+ sleep 5m
|
|
|
+ response=$(curl -X DELETE \
|
|
|
-H "Content-Type: application/json" \
|
|
|
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
|
|
|
- "https://api.digitalocean.com/v2/droplets?tag_name=$TAG"
|
|
|
+ -w "\n%{http_code}" \
|
|
|
+ "https://api.digitalocean.com/v2/droplets?tag_name=$TAG")
|
|
|
+
|
|
|
+ status_code=$(echo "$response" | tail -n1)
|
|
|
+ body=$(echo "$response" | sed '$d')
|
|
|
+
|
|
|
+ echo "Response body: $body"
|
|
|
+ echo "Status code: $status_code"
|
|
|
+
|
|
|
+ if [ "$status_code" -eq 204 ]; then
|
|
|
+ echo "Droplets deleted successfully"
|
|
|
+ else
|
|
|
+ echo "Failed to delete droplets. Status code: $status_code"
|
|
|
+ exit 1
|
|
|
+ fi
|
|
|
env:
|
|
|
DIGITALOCEAN_TOKEN: ${{ secrets.DIGITALOCEAN_TOKEN }}
|
|
|
TAG: ${{ github.event.workflow_run.id }}-${{ github.event.workflow_run.run_attempt }}
|