mirror of
https://github.com/seepine/action-setup-pnpm.git
synced 2025-01-18 14:16:35 +08:00
first commit
This commit is contained in:
commit
0b86b95ff8
16
.editorconfig
Normal file
16
.editorconfig
Normal file
@ -0,0 +1,16 @@
|
||||
# Editor configuration, see http://editorconfig.org
|
||||
|
||||
# 表示是最顶层的 EditorConfig 配置文件
|
||||
root = true
|
||||
|
||||
[*] # 表示所有文件适用
|
||||
charset = utf-8 # 设置文件字符集为 utf-8
|
||||
indent_style = space # 缩进风格(tab | space)
|
||||
indent_size = 2 # 缩进大小
|
||||
end_of_line = lf # 控制换行类型(lf | cr | crlf)
|
||||
trim_trailing_whitespace = true # 去除行首的任意空白字符
|
||||
insert_final_newline = true # 始终在文件末尾插入一个新行
|
||||
|
||||
[*.md] # 表示仅 md 文件适用以下规则
|
||||
max_line_length = off
|
||||
trim_trailing_whitespace = false
|
35
.gitattributes
vendored
Normal file
35
.gitattributes
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
* text=auto
|
||||
|
||||
# Force the following filetypes to have unix eols, so Windows does not break them
|
||||
*.* text eol=lf
|
||||
|
||||
# Separate configuration for files without suffix
|
||||
LICENSE text eol=lf
|
||||
Dockerfile text eol=lf
|
||||
pre-commit text eol=lf
|
||||
commit-msg text eol=lf
|
||||
|
||||
# These files are binary and should be left untouched
|
||||
# (binary is a macro for -text -diff)
|
||||
*.ico binary
|
||||
*.jpg binary
|
||||
*.jpeg binary
|
||||
*.png binary
|
||||
|
||||
*.pdf binary
|
||||
*.doc binary
|
||||
*.docx binary
|
||||
*.ppt binary
|
||||
*.pptx binary
|
||||
*.xls binary
|
||||
*.xlsx binary
|
||||
|
||||
*.exe binary
|
||||
*.jar binary
|
||||
|
||||
*.ttf binary
|
||||
*.woff binary
|
||||
*.woff2 binary
|
||||
*.eot binary
|
||||
*.otf binary
|
||||
# Add more binary...
|
30
.gitignore
vendored
Normal file
30
.gitignore
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
node_modules
|
||||
.DS_Store
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# local env files
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# Log files
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
|
||||
# Editor directories and files
|
||||
.idea
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
|
||||
# vuepress
|
||||
.temp
|
||||
.cache
|
||||
|
||||
package-lock.json
|
||||
yarn.lock
|
18
README.md
Normal file
18
README.md
Normal file
@ -0,0 +1,18 @@
|
||||
# actions-setup-pnpm
|
||||
|
||||
> Use corepack, if you want to set pnpm version, setting the packageManager field in package.json like `"packageManager":"pnpm@8.10.2"`
|
||||
|
||||
## Usage
|
||||
|
||||
```yml
|
||||
- name: Setup pnpm and Install
|
||||
uses: seepine/actions-setup-pnpm@v1
|
||||
```
|
||||
|
||||
## Input
|
||||
|
||||
|
||||
| Output Item | Description | Required | Default |
|
||||
| ------------ | ------------------------------------------------------------------------------------------------------ | -------- | ------- |
|
||||
| run_instasll | The working dir for the action | false | true |
|
||||
| cwd | Changes node's process.cwd() if the project is not located on the root. Default to process.cwd() files | false | . |
|
65
action.yml
Normal file
65
action.yml
Normal file
@ -0,0 +1,65 @@
|
||||
name: 'PNPM install'
|
||||
description: 'Setup pnpm and run pnpm install with cache enabled'
|
||||
|
||||
inputs:
|
||||
run_install:
|
||||
description: If specified, run `pnpm install`
|
||||
required: false
|
||||
default: 'true'
|
||||
cwd:
|
||||
description: "Changes node's process.cwd() if the project is not located on the root. Default to process.cwd()"
|
||||
required: false
|
||||
default: '.'
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
# If you want to set pnpm version, setting the packageManager field in package.json like "packageManager":"pnpm@8.10.2"
|
||||
- name: ⚙️ Enable Corepack
|
||||
shell: bash
|
||||
working-directory: ${{ inputs.cwd }}
|
||||
run: |
|
||||
corepack enable
|
||||
corepack enable npm
|
||||
echo "corepack enabled"
|
||||
echo "pnpm version : $(pnpm -v)"
|
||||
echo "pnpm store path : $(pnpm store path)"
|
||||
|
||||
- name: Expose pnpm config(s) through "$GITHUB_OUTPUT"
|
||||
id: pnpm-config
|
||||
shell: bash
|
||||
run: |
|
||||
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Cache rotation keys
|
||||
id: cache-rotation
|
||||
shell: bash
|
||||
run: |
|
||||
echo "YEAR_MONTH=$(/bin/date -u "+%Y%m")" >> $GITHUB_OUTPUT
|
||||
|
||||
- uses: seepine/hash-files@v1
|
||||
name: Get hash of lock files
|
||||
id: get-hash
|
||||
with:
|
||||
patterns: |
|
||||
**/pnpm-lock.yaml
|
||||
|
||||
- uses: actions/cache@v3
|
||||
name: Setup pnpm cache
|
||||
with:
|
||||
path: ${{ steps.pnpm-config.outputs.STORE_PATH }}
|
||||
key: ${{ runner.os }}-pnpm-store-cache-${{ steps.cache-rotation.outputs.YEAR_MONTH }}-${{ steps.get-hash.outputs.hash }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pnpm-store-cache-${{ steps.cache-rotation.outputs.YEAR_MONTH }}-
|
||||
|
||||
- name: Install dependencies
|
||||
if: ${{ inputs.run_install == 'true' }}
|
||||
shell: bash
|
||||
working-directory: ${{ inputs.cwd }}
|
||||
run: pnpm install --frozen-lockfile --prefer-offline
|
||||
env:
|
||||
HUSKY: '0'
|
||||
|
||||
- run: |
|
||||
echo ""
|
||||
echo "Setup pnpm finish."
|
Loading…
x
Reference in New Issue
Block a user