Skip to content

Commit 2bb6e4f

Browse files
committed
fix source check
1 parent 368f11f commit 2bb6e4f

1 file changed

Lines changed: 6 additions & 20 deletions

File tree

.github/workflows/clear_cache.yml

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,17 @@ jobs:
2929
-H "Content-Type: application/json" \
3030
"https://api.digitalocean.com/v2/apps/$app_id/deployments?page=1&per_page=1")
3131
32-
echo "Raw API Response:"
33-
echo "$response" | jq '.'
34-
3532
created_at=$(echo $response | jq -r '.deployments[0].created_at')
3633
status=$(echo $response | jq -r '.deployments[0].phase')
34+
commit_hash=$(echo $response | jq -r '.deployments[0].services[0].source_commit_hash')
3735
38-
# Try different possible commit hash fields
39-
commit_hash=$(echo $response | jq -r '.deployments[0].source_commit_hash')
40-
echo "source_commit_hash: $commit_hash"
41-
42-
commit_hash=$(echo $response | jq -r '.deployments[0].commit_hash')
43-
echo "commit_hash: $commit_hash"
44-
45-
commit_hash=$(echo $response | jq -r '.deployments[0].source.commit_hash')
46-
echo "source.commit_hash: $commit_hash"
47-
48-
commit_hash=$(echo $response | jq -r '.deployments[0].source.commit')
49-
echo "source.commit: $commit_hash"
50-
51-
echo "Latest deployment status: $status (created: $created_at)"
36+
echo "Latest deployment status: $status (created: $created_at, commit: $commit_hash)"
5237
53-
# Check if deployment is from last 10 minutes and is active
38+
# Check if deployment is from last 10 minutes, is active, and matches our commit
5439
if [ "$status" = "ACTIVE" ] && \
55-
[ $(( $(date +%s) - $(date -d "$created_at" +%s) )) -lt 300 ]; then
56-
echo "Found recent successful deployment"
40+
[ $(( $(date +%s) - $(date -d "$created_at" +%s) )) -lt 300 ] && \
41+
[ "$commit_hash" = "$CURRENT_COMMIT" ]; then
42+
echo "Found recent successful deployment matching current commit"
5743
echo "status=success" >> $GITHUB_OUTPUT
5844
exit 0
5945
fi

0 commit comments

Comments
 (0)