From b45eb203d6f39ad85d14459adfff7569761243dc Mon Sep 17 00:00:00 2001 From: Scion Date: Thu, 12 Mar 2026 18:34:44 -0700 Subject: [PATCH] Support public registries. --- npm/npm-test/action.yaml | 2 +- npm/npm-test/configure-auth.sh | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/npm/npm-test/action.yaml b/npm/npm-test/action.yaml index 983492b..adb1cb0 100644 --- a/npm/npm-test/action.yaml +++ b/npm/npm-test/action.yaml @@ -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: diff --git a/npm/npm-test/configure-auth.sh b/npm/npm-test/configure-auth.sh index 6926642..360530d 100644 --- a/npm/npm-test/configure-auth.sh +++ b/npm/npm-test/configure-auth.sh @@ -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