Support public registries.
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user