@@ -25,24 +25,64 @@ 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+
61+ while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do
62+ echo ""
63+ echo "📥 Attempt $ATTEMPT of $MAX_ATTEMPTS..."
64+
65+ # Use gh CLI to download artifact
66+ if gh run download "$RUN_ID" \
67+ --name "$ARTIFACT_NAME" \
68+ --dir "$EXTRACT_PATH" \
69+ --repo "$GITHUB_REPOSITORY"; then
70+ echo "✅ Successfully downloaded artifact on attempt $ATTEMPT"
71+ echo "::endgroup::"
72+ exit 0
73+ fi
74+
75+ if [ $ATTEMPT -lt $MAX_ATTEMPTS ]; then
76+ echo "::warning::Attempt $ATTEMPT failed, retrying in ${RETRY_DELAY}s..."
77+ sleep "$RETRY_DELAY"
78+ else
79+ echo "::error::❌ All $MAX_ATTEMPTS attempts failed to download artifact: $ARTIFACT_NAME"
80+ echo "::endgroup::"
81+ exit 1
82+ fi
83+
84+ ATTEMPT=$((ATTEMPT + 1))
85+ done
4686
4787 - name : Extract artifact
4888 shell : bash
0 commit comments