7 Commits

Author SHA1 Message Date
2270f39ef6 v2.1.0 2022-02-08 19:53:18 +07:00
394c848db6 Update the bundle 2022-02-08 19:50:57 +07:00
e13928ccc5 Merge pull request #27 from metonym/fix-jobs-syntax
Specify job name to fix syntax error
2022-02-08 19:48:36 +07:00
93bd5a123d Merge pull request #29 from pnpm/pnpm-v7
The pnpm home directory should be added to PATH and PNPM_HOME
2022-02-08 19:47:28 +07:00
9eb14dd77c decrease bundle size 2022-02-08 14:44:50 +02:00
eafb777c56 download script from pnpm.io 2022-02-08 00:39:20 +02:00
45d9c91ff6 Specify job name to fix syntax error 2022-01-29 08:17:29 -08:00
3 changed files with 41 additions and 38 deletions

View File

@ -54,12 +54,13 @@ on:
- pull_request
jobs:
runs-on: ubuntu-latest
install:
runs-on: ubuntu-latest
steps:
- uses: pnpm/action-setup@v2.0.1
with:
version: 6.0.2
steps:
- uses: pnpm/action-setup@v2.1.0
with:
version: 6.0.2
```
### Install pnpm and a few npm packages
@ -70,18 +71,19 @@ on:
- pull_request
jobs:
runs-on: ubuntu-latest
install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
steps:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v2.0.1
with:
version: 6.0.2
run_install: |
- recursive: true
args: [--frozen-lockfile, --strict-peer-dependencies]
- args: [--global, gulp, prettier, typescript]
- uses: pnpm/action-setup@v2.1.0
with:
version: 6.0.2
run_install: |
- recursive: true
args: [--frozen-lockfile, --strict-peer-dependencies]
- args: [--global, gulp, prettier, typescript]
```
### Use cache to reduce installation time
@ -92,24 +94,25 @@ on:
- pull_request
jobs:
runs-on: ubuntu-latest
cache-and-install:
runs-on: ubuntu-latest
steps:
build:
- uses: actions/checkout@v2
steps:
build:
- uses: actions/checkout@v2
- name: Cache pnpm modules
uses: actions/cache@v2
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
- name: Cache pnpm modules
uses: actions/cache@v2
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
- uses: pnpm/action-setup@v2.0.1
with:
version: 6.0.2
run_install: true
- uses: pnpm/action-setup@v2.1.0
with:
version: 6.0.2
run_install: true
```
**Note:** You don't need to run `pnpm store prune` at the end; post-action has already taken care of that.

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
import * as core from '@actions/core'
import { addPath, exportVariable } from '@actions/core'
import { spawn } from 'child_process'
import { execPath } from 'process'
import { join } from 'path'
import path from 'path'
import { remove, ensureFile, writeFile } from 'fs-extra'
import fetch from 'node-fetch'
import { Inputs } from '../inputs'
@ -9,7 +9,7 @@ import { Inputs } from '../inputs'
export async function runSelfInstaller(inputs: Inputs): Promise<number> {
const { version, dest } = inputs
const target = version ? `pnpm@${version}` : 'pnpm'
const pkgJson = join(dest, 'package.json')
const pkgJson = path.join(dest, 'package.json')
await remove(dest)
await ensureFile(pkgJson)
@ -20,7 +20,7 @@ export async function runSelfInstaller(inputs: Inputs): Promise<number> {
stdio: ['pipe', 'inherit', 'inherit'],
})
const response = await fetch('https://pnpm.js.org/pnpm.js')
const response = await fetch('https://pnpm.io/pnpm.js')
response.body.pipe(cp.stdin)
const exitCode = await new Promise<number>((resolve, reject) => {
@ -28,9 +28,9 @@ export async function runSelfInstaller(inputs: Inputs): Promise<number> {
cp.on('close', resolve)
})
if (exitCode === 0) {
const pnpmHome = join(dest, 'node_modules/.bin')
core.addPath(pnpmHome)
core.exportVariable('PNPM_HOME', pnpmHome)
const pnpmHome = path.join(dest, 'node_modules/.bin')
addPath(pnpmHome)
exportVariable('PNPM_HOME', pnpmHome)
}
return exitCode
}