first commit
This commit is contained in:
47
action.yml
Normal file
47
action.yml
Normal file
@@ -0,0 +1,47 @@
|
||||
name: Install node packages
|
||||
description: An action to install node packages, no matter the package manager
|
||||
author: Skydust
|
||||
|
||||
# Define your inputs here.
|
||||
inputs:
|
||||
path:
|
||||
description: The package path
|
||||
required: false
|
||||
default: "."
|
||||
options:
|
||||
description: Package manager options
|
||||
required: false
|
||||
default: ""
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Installing package manager
|
||||
shell: sh
|
||||
run: |
|
||||
cd "${{ inputs.path }}"
|
||||
if ! corepack install; then
|
||||
log_info "$(blue)Finding out the package manager used"
|
||||
|
||||
PKG_MANAGER="npm"
|
||||
if [ -f "./package-lock.json" ]; then
|
||||
PKG_MANAGER="npm"
|
||||
elif [ -f "./pnpm-lock.yaml" ]; then
|
||||
PKG_MANAGER="pnpm"
|
||||
elif [ -f "./.yarnrc.yml" ]; then
|
||||
PKG_MANAGER="yarn"
|
||||
elif [ -f "./yarn.lock ]; then
|
||||
PKG_MANAGER="yarn@1"
|
||||
fi
|
||||
|
||||
log_info "$(blue)Using $PKG_MANAGER"
|
||||
corepack use "$PKG_MANAGER"
|
||||
fi
|
||||
- name: Installing packages
|
||||
shell: sh
|
||||
run: |
|
||||
cd "${{ inputs.path }}"
|
||||
|
||||
PKG_MANAGER="$(sed -nE 's/.*"packageManager": *"([^@"]+).*/\1/p' package.json)"
|
||||
log_info "$(blue)Installing with ${PKG_MANAGER}"
|
||||
corepack "${PKG_MANAGER}" install ${{ inputs.options }}
|
||||
Reference in New Issue
Block a user