@@ -25,24 +25,67 @@ inputs:
2525 description : " Whether to remove downloaded artifacts after copying (true/false)"
2626 required : false
2727 default : " false"
28+ max-retries :
29+ description : " Maximum number of retry attempts for artifact download (total attempts = max-retries + 1)"
30+ required : false
31+ default : " 2"
32+ retry-delay-seconds :
33+ description : " Delay in seconds between retry attempts"
34+ required : false
35+ default : " 10"
2836
2937runs :
3038 using : " composite"
3139 steps :
3240 - name : Download artifact
3341 shell : bash
42+ env :
43+ ARTIFACT_NAME : ${{ inputs.artifact-name }}
44+ GH_TOKEN : ${{ inputs.gh-token }}
45+ RUN_ID : ${{ inputs.run-id }}
46+ EXTRACT_PATH : ${{ inputs.extract-path }}
47+ MAX_RETRIES : ${{ inputs.max-retries }}
48+ RETRY_DELAY : ${{ inputs.retry-delay-seconds }}
3449 run : |
35- echo "::group::📦 Downloading ${{ inputs.artifact-name }}"
36- echo "Artifact: ${{ inputs.artifact-name }}"
37- echo "Run ID: ${{ inputs.run-id }}"
38- echo "::endgroup::"
39-
40- - uses : actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
41- with :
42- name : ${{ inputs.artifact-name }}
43- github-token : ${{ inputs.gh-token }}
44- run-id : ${{ inputs.run-id }}
45- path : ${{ inputs.extract-path }}
50+ echo "::group::📦 Downloading $ARTIFACT_NAME"
51+ echo "Artifact: $ARTIFACT_NAME"
52+ echo "Run ID: $RUN_ID"
53+ echo "Max retries: $MAX_RETRIES"
54+
55+ # Create extract path if it doesn't exist
56+ mkdir -p "$EXTRACT_PATH"
57+
58+ ATTEMPT=1
59+ MAX_ATTEMPTS=$((MAX_RETRIES + 1))
60+ CURRENT_DELAY=$RETRY_DELAY
61+
62+ while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do
63+ echo ""
64+ echo "📥 Attempt $ATTEMPT of $MAX_ATTEMPTS..."
65+
66+ # Use gh CLI to download artifact
67+ if gh run download "$RUN_ID" \
68+ --name "$ARTIFACT_NAME" \
69+ --dir "$EXTRACT_PATH" \
70+ --repo "$GITHUB_REPOSITORY"; then
71+ echo "✅ Successfully downloaded artifact on attempt $ATTEMPT"
72+ echo "::endgroup::"
73+ exit 0
74+ fi
75+
76+ if [ $ATTEMPT -lt $MAX_ATTEMPTS ]; then
77+ echo "::warning::Attempt $ATTEMPT failed, retrying in ${CURRENT_DELAY}s (exponential backoff)..."
78+ sleep "$CURRENT_DELAY"
79+ # Exponential backoff: double the delay for next attempt
80+ CURRENT_DELAY=$((CURRENT_DELAY * 2))
81+ else
82+ echo "::error::❌ All $MAX_ATTEMPTS attempts failed to download artifact: $ARTIFACT_NAME"
83+ echo "::endgroup::"
84+ exit 1
85+ fi
86+
87+ ATTEMPT=$((ATTEMPT + 1))
88+ done
4689
4790 - name : Extract artifact
4891 shell : bash
0 commit comments