Skip to content

Commit c012721

Browse files
authored
Merge pull request #97 from Staffbase/fix-retry
fix retag retry
2 parents afe4a1e + cc53780 commit c012721

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

action.yml

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -179,28 +179,37 @@ runs:
179179
echo "RELEASE_TAG: ${RELEASE_TAG:1}"
180180
echo "Check if an image already exists for ${{ inputs.docker-image }}:main|master-${GITHUB_SHA::8} 🐋 ⬇"
181181
182-
MANIFEST=""
183-
for tag in $CHECK_EXISTING_TAGS; do
184-
MANIFEST=$(curl -H "Accept: ${CONTENT_TYPE}" -u '${{ inputs.docker-username }}:${{ inputs.docker-password }}' "${{ inputs.docker-registry-api }}${{ inputs.docker-image}}/manifests/${tag}")
182+
foundImage=false
185183
186-
if [[ $MANIFEST == *"errors"* ]]; then
187-
echo "No image found for ${{ inputs.docker-image }}:${tag} 🚫"
188-
continue
189-
else
190-
echo "Image found for ${{ inputs.docker-image }}:${tag} 🐋 ⬇"
191-
break
192-
fi
193-
# Exit here if no existing manifest was found
194-
exit 1
195-
done
196-
197-
echo "Retagging image with release version and :latest tags for ${{ inputs.docker-image }} 🏷"
198184
end=$((SECONDS+300))
199185
while [ $SECONDS -lt $end ]; do
200-
curl --fail-with-body -X PUT -H "Content-Type: ${CONTENT_TYPE}" -u '${{ inputs.docker-username }}:${{ inputs.docker-password }}' -d "${MANIFEST}" "${{ inputs.docker-registry-api }}${{ inputs.docker-image}}/manifests/${{ steps.preparation.outputs.tag }}" &&
201-
curl --fail-with-body -X PUT -H "Content-Type: ${CONTENT_TYPE}" -u '${{ inputs.docker-username }}:${{ inputs.docker-password }}' -d "${MANIFEST}" "${{ inputs.docker-registry-api }}${{ inputs.docker-image}}/manifests/${{ steps.preparation.outputs.latest }}" && break
186+
187+
MANIFEST=""
188+
for tag in $CHECK_EXISTING_TAGS; do
189+
MANIFEST=$(curl -H "Accept: ${CONTENT_TYPE}" -u '${{ inputs.docker-username }}:${{ inputs.docker-password }}' "${{ inputs.docker-registry-api }}${{ inputs.docker-image}}/manifests/${tag}")
190+
191+
if [[ $MANIFEST == *"errors"* ]]; then
192+
echo "No image found for ${{ inputs.docker-image }}:${tag} 🚫"
193+
continue
194+
else
195+
echo "Image found for ${{ inputs.docker-image }}:${tag} 🐋 ⬇"
196+
foundImage=true
197+
break 2
198+
fi
199+
done
200+
202201
sleep 10
203202
done
203+
204+
if [[ $foundImage == false ]]; then
205+
echo "No image found for ${{ inputs.docker-image }}:main|master-${GITHUB_SHA::8} 🚫 within 300 seconds"
206+
exit 1
207+
fi
208+
209+
echo "Retagging image with release version and :latest tags for ${{ inputs.docker-image }} 🏷"
210+
curl --fail-with-body -X PUT -H "Content-Type: ${CONTENT_TYPE}" -u '${{ inputs.docker-username }}:${{ inputs.docker-password }}' -d "${MANIFEST}" "${{ inputs.docker-registry-api }}${{ inputs.docker-image}}/manifests/${{ steps.preparation.outputs.tag }}"
211+
curl --fail-with-body -X PUT -H "Content-Type: ${CONTENT_TYPE}" -u '${{ inputs.docker-username }}:${{ inputs.docker-password }}' -d "${MANIFEST}" "${{ inputs.docker-registry-api }}${{ inputs.docker-image}}/manifests/${{ steps.preparation.outputs.latest }}"
212+
204213
- name: Checkout GitOps Repository
205214
if: inputs.gitops-token != ''
206215
uses: actions/checkout@v4

0 commit comments

Comments
 (0)