Support public registries.

This commit is contained in:
2026-03-12 18:34:44 -07:00
parent 8aedcefc54
commit b45eb203d6
2 changed files with 13 additions and 7 deletions

View File

@@ -14,7 +14,7 @@ inputs:
required: false
default: "${{ github.server_url }}/api/packages/${{ github.repository_owner }}/npm/index.json"
apiKeys:
description: "Newline-separated list of API keys corresponding to registries."
description: "Newline-separated list of API keys corresponding to registries. Use 'none' for public registries."
required: false
default: "${{ github.token }}"
testCommand:

View File

@@ -6,13 +6,13 @@ AUTH_URLS="$2"
API_KEYS="$3"
if [ "$ACTION" == "add" ]; then
# Parse newline-separated URLs and tokens into arrays
IFS=$'\n' read -rd '' -a URLS <<< "$AUTH_URLS" || true
IFS=$'\n' read -rd '' -a KEYS <<< "$API_KEYS" || true
# Parse newline-separated URLs and tokens into arrays (preserves empty lines)
mapfile -t URLS <<< "$AUTH_URLS"
mapfile -t KEYS <<< "$API_KEYS"
# Verify arrays have matching lengths
if [ ${#URLS[@]} -ne ${#KEYS[@]} ]; then
echo "Error: Number of authUrls (${#URLS[@]}) does not match number of apiKeys (${#KEYS[@]})"
echo "Error: Number of registries (${#URLS[@]}) does not match number of apiKeys (${#KEYS[@]})"
exit 1
fi
@@ -21,8 +21,14 @@ if [ "$ACTION" == "add" ]; then
URL="${URLS[$i]}"
KEY="${KEYS[$i]}"
# Skip empty entries
if [ -z "$URL" ] || [ -z "$KEY" ]; then
# Skip empty registry entries
if [ -z "$URL" ]; then
continue
fi
# Skip registries that don't need authentication
if [ -z "$KEY" ] || [ "$KEY" == "none" ]; then
echo "Skipping authentication for: $URL (no API key provided)"
continue
fi