@@ -55,33 +55,45 @@ runs:
55
55
56
56
echo "::notice::${{ inputs.release-type }} workflow triggered successfully"
57
57
58
- - name : Find ${{ inputs.release-type }} Workflow Run
58
+ - name : Find ${{ inputs.run-name }} Workflow Run
59
59
id : find-workflow
60
60
shell : bash
61
61
env :
62
62
GH_TOKEN : ${{ inputs.github-token }}
63
63
run : |
64
- echo "::notice::Waiting for ${{ inputs.release-type }} workflow to appear in run list..."
65
-
66
- # Wait for the workflow to appear in the list
67
- sleep 5
64
+ echo "::notice::Waiting for ${{ inputs.run-name }} workflow to appear in run list..."
68
65
69
- # gh run list --workflow "release-stage-2_build_and_release.yml" --event workflow_dispatch --json url,name --jq '[.[] | select(.name | contains("Scheduled - beta"))] | .[].url'
66
+ # Initialize variables
67
+ WORKFLOW_URL=""
68
+ MAX_RETRIES=12 # Retry for up to 1 minute (12 retries * 5 seconds)
69
+ RETRY_COUNT=0
70
+
71
+ # Retry loop
72
+ while [[ -z "$WORKFLOW_URL" || "$WORKFLOW_URL" == "null" ]]; do
73
+ if [[ $RETRY_COUNT -ge $MAX_RETRIES ]]; then
74
+ echo "::error::Could not find triggered ${{ inputs.run-name }} workflow run after 1 minute"
75
+ gh run list --workflow "${{ inputs.workflow-file }}" --event workflow_dispatch --branch "${{ inputs.ref }}" --limit 5 --json url,name
76
+ exit 1
77
+ fi
78
+
79
+ # Increment retry count
80
+ RETRY_COUNT=$((RETRY_COUNT + 1))
81
+
82
+ # Check for the workflow run
83
+ WORKFLOW_URL=$(gh run list --workflow "${{ inputs.workflow-file }}" \
84
+ --event workflow_dispatch \
85
+ --branch "${{ inputs.ref }}" \
86
+ --limit 1 \
87
+ --json url,name \
88
+ --jq '[.[] | select(.name | contains("${{ inputs.run-name }}"))] | .[].url' | \
89
+ head -n 1)
90
+
91
+ if [[ -z "$WORKFLOW_URL" || "$WORKFLOW_URL" == "null" ]]; then
92
+ echo "::notice::Retry $RETRY_COUNT/$MAX_RETRIES: ${{ inputs.release-type }} workflow not found. Retrying in 5 seconds..."
93
+ sleep 5
94
+ fi
95
+ done
70
96
71
- # Get the URL of the most recent workflow run
72
- WORKFLOW_URL=$(gh run list --workflow "${{ inputs.workflow-file }}" \
73
- --event workflow_dispatch \
74
- --branch "${{ inputs.ref }}" \
75
- --limit 1 \
76
- --json url,name \
77
- --jq '[.[] | select(.name | contains("${{ inputs.run-name }}"))] | .[].url' | \
78
- head -n 1)
79
- if [[ -z "$WORKFLOW_URL" || "$WORKFLOW_URL" == "null" ]]; then
80
- echo "::error::Could not find triggered ${{ inputs.run-name }} workflow run"
81
- gh run list --workflow "${{ inputs.workflow-file }}" --event workflow_dispatch --branch "${{ inputs.ref }}" --limit 5 --json url,name
82
- exit 1
83
- fi
84
-
85
97
echo "::notice::Found ${{ inputs.release-type }} workflow run: $WORKFLOW_URL"
86
98
echo "workflow_url=$WORKFLOW_URL" >> $GITHUB_OUTPUT
87
99
0 commit comments