fix(ci): verify anonymous GHCR pull even when visibility API is unavailable (#801)
This commit is contained in:
parent
50fd5b81e1
commit
80b60d7b70
1 changed files with 17 additions and 17 deletions
34
.github/workflows/pub-docker-img.yml
vendored
34
.github/workflows/pub-docker-img.yml
vendored
|
|
@ -139,32 +139,32 @@ jobs:
|
||||||
owner="${GITHUB_REPOSITORY_OWNER,,}"
|
owner="${GITHUB_REPOSITORY_OWNER,,}"
|
||||||
repo="${GITHUB_REPOSITORY#*/}"
|
repo="${GITHUB_REPOSITORY#*/}"
|
||||||
|
|
||||||
# Package path can be either "<repo>" or URL-encoded "<owner>/<repo>".
|
# Package path can vary depending on repository/package linkage.
|
||||||
candidates=(
|
candidates=(
|
||||||
"$repo"
|
"$repo"
|
||||||
"${owner}%2F${repo}"
|
"${owner}%2F${repo}"
|
||||||
)
|
)
|
||||||
|
|
||||||
for pkg in "${candidates[@]}"; do
|
for scope in orgs users; do
|
||||||
code="$(curl -sS -o /tmp/ghcr-visibility.json -w "%{http_code}" \
|
for pkg in "${candidates[@]}"; do
|
||||||
-X PATCH \
|
code="$(curl -sS -o /tmp/ghcr-visibility.json -w "%{http_code}" \
|
||||||
-H "Authorization: Bearer ${GH_TOKEN}" \
|
-X PATCH \
|
||||||
-H "Accept: application/vnd.github+json" \
|
-H "Authorization: Bearer ${GH_TOKEN}" \
|
||||||
-H "X-GitHub-Api-Version: 2022-11-28" \
|
-H "Accept: application/vnd.github+json" \
|
||||||
"https://api.github.com/orgs/${owner}/packages/container/${pkg}/visibility" \
|
-H "X-GitHub-Api-Version: 2022-11-28" \
|
||||||
-d '{"visibility":"public"}' || true)"
|
"https://api.github.com/${scope}/${owner}/packages/container/${pkg}/visibility" \
|
||||||
|
-d '{"visibility":"public"}' || true)"
|
||||||
|
|
||||||
if [ "$code" = "200" ] || [ "$code" = "204" ]; then
|
if [ "$code" = "200" ] || [ "$code" = "204" ]; then
|
||||||
echo "GHCR package visibility is public for ${pkg}."
|
echo "GHCR package visibility is public (${scope}/${owner}/${pkg})."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Attempt for ${pkg} returned HTTP ${code}."
|
echo "Visibility attempt ${scope}/${owner}/${pkg} returned HTTP ${code}."
|
||||||
cat /tmp/ghcr-visibility.json || true
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "::error::Failed to set GHCR package visibility to public."
|
echo "::warning::Unable to update GHCR visibility via API in this run; proceeding to direct anonymous pull verification."
|
||||||
exit 1
|
|
||||||
|
|
||||||
- name: Verify anonymous GHCR pull access
|
- name: Verify anonymous GHCR pull access
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue