Skip to content

Commit f135bd3

Browse files
jeffreys-catrschristianalanorozco
authored
[feature] Add install script inputs (#85)
* [feature] Add install script inputs * docs: Add docs for new `install-script` option Co-authored-by: Alan Orozco <alanorozco@users.noreply.github.com> * Update action.yml --------- Co-authored-by: Ryan Christian <rchristian@ryanchristian.dev> Co-authored-by: Alan Orozco <alanorozco@users.noreply.github.com> Co-authored-by: Ryan Christian <33403762+rschristian@users.noreply.github.com>
1 parent f2cd878 commit f135bd3

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,26 @@ jobs:
2929
- uses: preactjs/compressed-size-action@v2
3030
```
3131
32+
### Customizing the Installation
33+
34+
By default, `compressed-size-action` will install dependencies according to which lockfiles are present, if any. However, if you need to run a different installation command, you can pass a custom script to do so. For example, to use `npm ci` with the `--workspace` option:
35+
36+
```diff
37+
name: Compressed Size
38+
39+
on: [pull_request]
40+
41+
jobs:
42+
build:
43+
runs-on: ubuntu-latest
44+
45+
steps:
46+
- uses: actions/checkout@v2
47+
- uses: preactjs/compressed-size-action@v2
48+
with:
49+
+ install-script: "npm ci --workspace=packages/my-subpackage"
50+
```
51+
3252
### Customizing the Build
3353

3454
By default, `compressed-size-action` will try to build your PR by running the `"build"` [npm script](https://docs.npmjs.com/misc/scripts) in your `package.json`.

action.yml

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ inputs:
1111
default: ${{ github.token }}
1212
clean-script:
1313
description: 'An npm-script that cleans/resets state between branch builds'
14+
install-script:
15+
required: false
16+
description: 'Custom installation script to run to set up the dependencies in your project'
1417
build-script:
1518
description: 'The npm-script to run that builds your project'
1619
default: 'build'

index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.js

+8
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ async function run(octokit, context, token) {
7070
installScript = 'npm ci';
7171
}
7272

73+
if (getInput('install-script')) {
74+
installScript = getInput('install-script');
75+
}
76+
7377
startGroup(`[current] Install Dependencies`);
7478
console.log(`Installing using ${installScript}`);
7579
await exec(installScript);
@@ -143,6 +147,10 @@ async function run(octokit, context, token) {
143147
installScript = `npm ci`;
144148
}
145149

150+
if (getInput('install-script')) {
151+
installScript = getInput('install-script');
152+
}
153+
146154
console.log(`Installing using ${installScript}`);
147155
await exec(installScript);
148156
endGroup();

0 commit comments

Comments
 (0)