|
| 1 | +# Docker.md |
| 2 | +https://github.com/AS-BIG-FEMALE/.github-DEVELOPMENT.md/issues/9#issuecomment-2117984653 |
| 3 | + |
| 4 | +# Setup pnpm |
| 5 | + |
| 6 | +Install pnpm package manager. |
| 7 | + |
| 8 | +## Inputs |
| 9 | + |
| 10 | +### `version` |
| 11 | + |
| 12 | +Version of pnpm to install. |
| 13 | + |
| 14 | +**Optional** when there is a [`packageManager` field in the `package.json`](https://nodejs.org/api/corepack.html). |
| 15 | + |
| 16 | +otherwise, this field is **required** It supports npm versioning scheme, it could be an exact version (such as `6.24.1`), or a version range (such as `6`, `6.x.x`, `6.24.x`, `^6.24.1`, `*`, etc.), or `latest`. |
| 17 | + |
| 18 | +### `dest` |
| 19 | + |
| 20 | +**Optional** Where to store pnpm files. |
| 21 | + |
| 22 | +### `run_install` |
| 23 | + |
| 24 | +**Optional** (_default:_ `null`) If specified, run `pnpm install`. |
| 25 | + |
| 26 | +If `run_install` is either `null` or `false`, pnpm will not install any npm package. |
| 27 | + |
| 28 | +If `run_install` is `true`, pnpm will install dependencies recursively. |
| 29 | + |
| 30 | +If `run_install` is a YAML string representation of either an object or an array, pnpm will execute every install commands. |
| 31 | + |
| 32 | +#### `run_install.recursive` |
| 33 | + |
| 34 | +**Optional** (_type:_ `boolean`, _default:_ `false`) Whether to use `pnpm recursive install`. |
| 35 | + |
| 36 | +#### `run_install.cwd` |
| 37 | + |
| 38 | +**Optional** (_type:_ `string`) Working directory when run `pnpm [recursive] install`. |
| 39 | + |
| 40 | +#### `run_install.args` |
| 41 | + |
| 42 | +**Optional** (_type:_ `string[]`) Additional arguments after `pnpm [recursive] install`, e.g. `[--frozen-lockfile, --strict-peer-dependencies]`. |
| 43 | + |
| 44 | +### `package_json_file` |
| 45 | + |
| 46 | +**Optional** (_type:_ `string`, _default:_ `package.json`) File path to the `package.json` to read "packageManager" configuration. |
| 47 | + |
| 48 | +### `standalone` |
| 49 | + |
| 50 | +**Optional** (_type:_ `boolean`, _default:_ `false`) When set to true, [@pnpm/exe](https://www.npmjs.com/package/@pnpm/exe), which is a Node.js bundled package, will be installed, enabling using `pnpm` without Node.js. |
| 51 | + |
| 52 | +This is useful when you want to use a incompatible pair of Node.js and pnpm. |
| 53 | + |
| 54 | +## Outputs |
| 55 | + |
| 56 | +### `dest` |
| 57 | + |
| 58 | +Expanded path of inputs#dest. |
| 59 | + |
| 60 | +### `bin_dest` |
| 61 | + |
| 62 | +Location of `pnpm` and `pnpx` command. |
| 63 | + |
| 64 | +## Usage example |
| 65 | + |
| 66 | +### Just install pnpm |
| 67 | + |
| 68 | +```yaml |
| 69 | +on: |
| 70 | + - push |
| 71 | + - pull_request |
| 72 | + |
| 73 | +jobs: |
| 74 | + install: |
| 75 | + runs-on: ubuntu-latest |
| 76 | + |
| 77 | + steps: |
| 78 | + - uses: pnpm/action-setup@v4 |
| 79 | + with: |
| 80 | + version: 8 |
| 81 | +``` |
| 82 | +
|
| 83 | +### Install pnpm and a few npm packages |
| 84 | +
|
| 85 | +```yaml |
| 86 | +on: |
| 87 | + - push |
| 88 | + - pull_request |
| 89 | + |
| 90 | +jobs: |
| 91 | + install: |
| 92 | + runs-on: ubuntu-latest |
| 93 | + |
| 94 | + steps: |
| 95 | + - uses: actions/checkout@v4 |
| 96 | + |
| 97 | + - uses: pnpm/action-setup@v4 |
| 98 | + with: |
| 99 | + version: 8 |
| 100 | + run_install: | |
| 101 | + - recursive: true |
| 102 | + args: [--frozen-lockfile, --strict-peer-dependencies] |
| 103 | + - args: [--global, gulp, prettier, typescript] |
| 104 | +``` |
| 105 | +
|
| 106 | +### Use cache to reduce installation time |
| 107 | +
|
| 108 | +```yaml |
| 109 | +on: |
| 110 | + - push |
| 111 | + - pull_request |
| 112 | + |
| 113 | +jobs: |
| 114 | + cache-and-install: |
| 115 | + runs-on: ubuntu-latest |
| 116 | + |
| 117 | + steps: |
| 118 | + - name: Checkout |
| 119 | + uses: actions/checkout@v4 |
| 120 | + |
| 121 | + - uses: pnpm/action-setup@v4 |
| 122 | + name: Install pnpm |
| 123 | + with: |
| 124 | + version: 8 |
| 125 | + run_install: false |
| 126 | + |
| 127 | + - name: Install Node.js |
| 128 | + uses: actions/setup-node@v4 |
| 129 | + with: |
| 130 | + node-version: 20 |
| 131 | + cache: 'pnpm' |
| 132 | + |
| 133 | + - name: Get pnpm store directory |
| 134 | + shell: bash |
| 135 | + run: | |
| 136 | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV |
| 137 | +
|
| 138 | + - uses: actions/cache@v4 |
| 139 | + name: Setup pnpm cache |
| 140 | + with: |
| 141 | + path: ${{ env.STORE_PATH }} |
| 142 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 143 | + restore-keys: | |
| 144 | + ${{ runner.os }}-pnpm-store- |
| 145 | +
|
| 146 | + - name: Install dependencies |
| 147 | + run: pnpm install |
| 148 | +``` |
| 149 | +
|
| 150 | +**Note:** You don't need to run `pnpm store prune` at the end; post-action has already taken care of that. |
| 151 | + |
| 152 | +## Notes |
| 153 | + |
| 154 | +This action does not setup Node.js for you, use [actions/setup-node](https://github.com/actions/setup-node) yourself. |
| 155 | + |
| 156 | +## License |
| 157 | + |
| 158 | +[MIT](https://github.com/pnpm/action-setup/blob/master/LICENSE.md) © [Hoàng Văn Khải](https://github.com/KSXGitHub/) |
0 commit comments