From cad475f67263d930b726c87b8e7f6a87439e655e Mon Sep 17 00:00:00 2001 From: Anand Tripathi Date: Thu, 1 Feb 2024 17:28:23 +0100 Subject: [PATCH] Update compile Added support for repository user --- bin/compile | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bin/compile b/bin/compile index f9ff16a..d713fde 100644 --- a/bin/compile +++ b/bin/compile @@ -1,11 +1,15 @@ #!/usr/bin/env bash ENV_DIR=${3:-} -build_dir=${1:-} -npmrc="$(cat $ENV_DIR/NPMRC)" +BUILD_DIR=${1:-} +GITHUB_TOKEN="$(cat $ENV_DIR/GITHUB_TOKEN)" +REPO_USER="$(cat $ENV_DIR/REPO_USER)" -if [ "$npmrc" != "" ]; then - echo "-----> Using .npmrc from config var NPMRC" - echo "$npmrc" > "$build_dir/.npmrc" + +if [ "$GITHUB_TOKEN" != "" ]; then + echo "-----> Using .npmrc to install packages from https://npm.pkg.github.com/$REPO_USER" + echo "@$REPO_USER:registry=https://npm.pkg.github.com/$REPO_USER" > "$BUILD_DIR/.npmrc" + echo "//npm.pkg.github.com/:_authToken=$GITHUB_TOKEN" >> "$BUILD_DIR/.npmrc" + echo "//npm.pkg.github.com/$REPO_USER/:_authToken=$GITHUB_TOKEN" >> "$BUILD_DIR/.npmrc" exit 0 fi