Skip to content

Commit

Permalink
Use curl best practices for CNB registry check (#141)
Browse files Browse the repository at this point in the history
Switched `curl` invocation to use head request, handle retries on error, return exit code, etc.
  • Loading branch information
colincasey authored Sep 25, 2023
1 parent 8516f42 commit 8f1d331
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/_buildpacks-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,12 @@ jobs:
- name: Check if version is already in the registry
id: check
run: |
export URL="https://registry.buildpacks.io/api/v1/buildpacks/${{ matrix.buildpack_id }}/${{ matrix.buildpack_version }}"
export EXISTS=$(if [ "$( curl -s -o /dev/null -I -w "%{http_code}" "${URL}")" = "200" ]; then echo 'true'; else echo 'false'; fi)
echo "published_to_cnb_registry=${EXISTS}" >> $GITHUB_OUTPUT
registry_url="https://registry.buildpacks.io/api/v1/buildpacks/${{ matrix.buildpack_id }}/${{ matrix.buildpack_version }}"
if curl --head --silent --show-error --fail --retry 1 --retry-all-errors --connect-timeout 10 --max-time 60 "${registry_url}"; then
echo "published_to_cnb_registry=true" >> $GITHUB_OUTPUT
else
echo "published_to_cnb_registry=false" >> $GITHUB_OUTPUT
fi
- name: Calculate the buildpack image digest
id: digest
Expand Down

0 comments on commit 8f1d331

Please sign in to comment.