Skip to content

Commit 8b815dc

Browse files
committed
Update action.yml
1 parent 11feea1 commit 8b815dc

File tree

1 file changed

+32
-20
lines changed
  • .github/actions/trigger-and-wait-workflow

1 file changed

+32
-20
lines changed

.github/actions/trigger-and-wait-workflow/action.yml

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,33 +55,45 @@ runs:
5555
5656
echo "::notice::${{ inputs.release-type }} workflow triggered successfully"
5757
58-
- name: Find ${{ inputs.release-type }} Workflow Run
58+
- name: Find ${{ inputs.run-name }} Workflow Run
5959
id: find-workflow
6060
shell: bash
6161
env:
6262
GH_TOKEN: ${{ inputs.github-token }}
6363
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..."
6865
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
7096
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-
8597
echo "::notice::Found ${{ inputs.release-type }} workflow run: $WORKFLOW_URL"
8698
echo "workflow_url=$WORKFLOW_URL" >> $GITHUB_OUTPUT
8799

0 commit comments

Comments
 (0)