@@ -21,16 +21,17 @@ counter=0
2121
2222# Get the current time in ISO 8601 format
2323current_time=$( date -u +" %Y-%m-%dT%H:%M:%SZ" )
24- start_time=${START_TIME:- $current_time }
24+ yesterday=$( date -u -d " yesterday" +" %Y-%m-%dT%H:%M:%SZ" )
25+ start_time=${START_TIME:- $yesterday }
2526
2627# Check if REF has the prefix "refs/heads/" and append it if not
2728if [[ ! " $REF " =~ ^refs/heads/ ]]; then
2829 REF=" refs/heads/$REF "
2930fi
3031
31- GITHUB_AUTH=
32+ HEADERS=(-H " Accept: application/vnd.github+json " )
3233if [ -n " ${GITHUB_TOKEN:- } " ]; then
33- GITHUB_AUTH= " -H \ " Authorization: token $GITHUB_TOKEN \" "
34+ HEADERS+=( -H " Authorization: token $GITHUB_TOKEN " )
3435fi
3536
3637echo " ℹ️ Organization: ${ORG_NAME} "
@@ -40,6 +41,9 @@ echo "ℹ️ Timeout to find the workflow: ${max_find_minutes} minutes"
4041echo " ℹ️ Timeout for the workflow to complete: ${timeout} minutes"
4142echo " ℹ️ Interval between checks: ${interval} seconds"
4243
44+ echo " ℹ️ Worflow Start Time: $start_time "
45+ echo " ℹ️ Current Time: $current_time "
46+
4347# If RUN_ID is not empty, use it directly
4448if [ -n " ${RUN_ID:- } " ]; then
4549 run_id=" ${RUN_ID} "
5155 # Wait for the workflow to be triggered
5256 while true ; do
5357 echo " ⏳ Waiting for the workflow to be found..."
54- response=$( curl -s -H " Accept: application/vnd.github+json " $GITHUB_AUTH \
58+ response=$( curl -s " ${HEADERS[@]} " \
5559 " https://api.github.com/repos/${ORG_NAME} /${REPO_NAME} /actions/workflows/${workflow_id} /runs" )
5660 if echo " $response " | grep -q " API rate limit exceeded" ; then
5761 echo " ❌ API rate limit exceeded. Please try again later."
9599timeout_counter=0
96100while true ; do
97101 echo " ⌛ Waiting for the workflow to complete..."
98- run_data=$( curl -s -H " Accept: application/vnd.github+json " $GITHUB_AUTH \
102+ run_data=$( curl -s " ${HEADERS[@]} " \
99103 " https://api.github.com/repos/${ORG_NAME} /${REPO_NAME} /actions/runs/$run_id " )
100104 status=$( echo " $run_data " | jq -r ' .status' )
101105
0 commit comments