-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflow that monitors the downstream test result.
- Loading branch information
1 parent
622e2ec
commit 5860402
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
|
||
# PAT_TOKEN and TARGET_BRANCH are passed in as environment variables. | ||
|
||
TARGET_REPO="aptos-labs/aptos-indexer-processors" | ||
WORKFLOW_NAME="sdk-dependency-update" | ||
MAX_RETRIES=30 | ||
RETRY_INTERVAL=60 # seconds | ||
|
||
echo "Monitoring workflow $WORKFLOW_NAME for branch $TARGET_BRANCH in $TARGET_REPO" | ||
|
||
for ((i=1; i<=MAX_RETRIES; i++)); do | ||
# Get the latest run of the workflow for the target branch | ||
response=$(curl -s -H "Authorization: token $PAT_TOKEN" \ | ||
"https://api.github.com/repos/$TARGET_REPO/actions/workflows/$WORKFLOW_NAME/runs?branch=$TARGET_BRANCH&status=in_progress") | ||
|
||
# Check if there is an in-progress run | ||
if echo "$response" | grep -q '"in_progress"'; then | ||
echo "Workflow still in progress... waiting." | ||
sleep $RETRY_INTERVAL | ||
else | ||
# Check the latest completed run for the branch | ||
response=$(curl -s -H "Authorization: token $PAT_TOKEN" \ | ||
"https://api.github.com/repos/$TARGET_REPO/actions/workflows/$WORKFLOW_NAME/runs?branch=$TARGET_BRANCH&status=completed") | ||
total_count=$(echo "$response" | jq -r '.total_count') | ||
if [ "$total_count" -gt 0 ]; then | ||
conclusion=$(echo "$response" | jq -r '.workflow_runs[0].conclusion') | ||
else | ||
echo "No workflow runs found for branch $TARGET_BRANCH" | ||
continue | ||
fi | ||
# If the workflow succeeds, exit with a zero status | ||
if [ "$conclusion" == "success" ]; then | ||
echo "Workflow completed successfully!" | ||
exit 0 | ||
fi | ||
# Otherwise, we retry. | ||
fi | ||
done | ||
|
||
echo "Workflow did not complete within the timeout period." | ||
exit 1 |