Compare commits

...

7 Commits

Author SHA1 Message Date
Khải 57b9359b4c Merge pull request #41 from nelson6e65/patch-1
docs(readme): improve Cache example
2022-05-07 10:00:37 +07:00
Khải ec1a8b444c Change runs-on back to ubuntu-latest 2022-05-07 09:59:56 +07:00
Nelson Martell 73e15250cb docs(readme): improve and fix cache example
Dynamically detect the Store directory and use the latest GitHub actions.
2022-05-06 21:57:00 -05:00
Khải 10b4b0b462 Merge pull request #36 from pnpm/dependabot/github_actions/actions/checkout-3
Bump actions/checkout from 2 to 3
2022-03-08 10:33:01 +07:00
Khải 5fa8980bf4 Update dependabot.yml 2022-03-08 10:32:48 +07:00
dependabot[bot] ae78e9abbe Bump actions/checkout from 2 to 3
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-07 23:02:26 +00:00
Jack Works 35ab4267a1 fix: packageManager reader (#35)
* fix: packageManager reader

* chore: resolve review

* chore: run build
2022-02-25 12:43:26 +08:00
6 changed files with 46 additions and 25 deletions
-3
View File
@@ -5,6 +5,3 @@ updates:
schedule:
interval: weekly
open-pull-requests-limit: 10
labels:
- dependabot
- github-actions
+3 -3
View File
@@ -22,7 +22,7 @@ jobs:
- windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Run the action
uses: ./
@@ -51,7 +51,7 @@ jobs:
- windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Run the action
uses: ./
@@ -107,7 +107,7 @@ jobs:
- pnpm
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Run the action
uses: ./
+26 -11
View File
@@ -102,21 +102,36 @@ jobs:
runs-on: ubuntu-latest
steps:
build:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v3
- name: Cache pnpm modules
uses: actions/cache@v2
- name: Install Node.js
uses: actions/setup-node@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
node-version: 16
- uses: pnpm/action-setup@v2.0.1
name: Install pnpm
id: pnpm-install
with:
version: 7
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
${{ runner.os }}-pnpm-store-
- uses: pnpm/action-setup@v2.1.0
with:
version: 6.0.2
run_install: true
- name: Install dependencies
run: pnpm install
```
**Note:** You don't need to run `pnpm store prune` at the end; post-action has already taken care of that.
-1
View File
@@ -6,7 +6,6 @@ branding:
inputs:
version:
description: Version of PNPM to install
required: true
dest:
description: Where to store PNPM files
required: false
+1 -1
View File
File diff suppressed because one or more lines are too long
+14 -4
View File
@@ -8,13 +8,15 @@ import { Inputs } from '../inputs'
export async function runSelfInstaller(inputs: Inputs): Promise<number> {
const { version, dest } = inputs
const pkgJson = path.join(dest, 'package.json')
const target = await readTarget(pkgJson, version)
// prepare self install
await remove(dest)
const pkgJson = path.join(dest, 'package.json')
await ensureFile(pkgJson)
await writeFile(pkgJson, JSON.stringify({ private: true }))
// prepare target pnpm
const target = await readTarget(version)
const cp = spawn(execPath, ['-', 'install', target, '--no-lockfile'], {
cwd: dest,
stdio: ['pipe', 'inherit', 'inherit'],
@@ -36,10 +38,18 @@ export async function runSelfInstaller(inputs: Inputs): Promise<number> {
return exitCode
}
async function readTarget(packageJsonPath: string, version?: string | undefined) {
async function readTarget(version?: string | undefined) {
if (version) return `pnpm@${version}`
const { packageManager } = JSON.parse(await readFile(packageJsonPath, 'utf8'))
const { GITHUB_WORKSPACE } = process.env
if (!GITHUB_WORKSPACE) {
throw new Error(`No workspace is found.
If you're intended to let pnpm/action-setup read preferred pnpm version from the "packageManager" field in the package.json file,
please run the actions/checkout before pnpm/action-setup.
Otherwise, please specify the pnpm version in the action configuration.`)
}
const { packageManager } = JSON.parse(await readFile(path.join(GITHUB_WORKSPACE, 'package.json'), 'utf8'))
if (typeof packageManager !== 'string') {
throw new Error(`No pnpm version is specified.
Please specify it by one of the following ways: