Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Add install script inputs #85

Merged
merged 3 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,26 @@ jobs:
- uses: preactjs/compressed-size-action@v2
```
### Customizing the Installation
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:

```diff
name: Compressed Size
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: preactjs/compressed-size-action@v2
with:
+ install-script: "npm ci --workspace=packages/my-subpackage"
```

### Customizing the Build

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`.
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ inputs:
default: ${{ github.token }}
clean-script:
description: 'An npm-script that cleans/resets state between branch builds'
install-script:
required: false
description: 'The npm-script to run that install dependencies in your project'
rschristian marked this conversation as resolved.
Show resolved Hide resolved
build-script:
description: 'The npm-script to run that builds your project'
default: 'build'
Expand Down
2 changes: 1 addition & 1 deletion index.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ async function run(octokit, context, token) {
installScript = 'npm ci';
}

if (getInput('install-script')) {
installScript = getInput('install-script');
}

startGroup(`[current] Install Dependencies`);
console.log(`Installing using ${installScript}`);
await exec(installScript);
Expand Down Expand Up @@ -143,6 +147,10 @@ async function run(octokit, context, token) {
installScript = `npm ci`;
}

if (getInput('install-script')) {
installScript = getInput('install-script');
}

console.log(`Installing using ${installScript}`);
await exec(installScript);
endGroup();
Expand Down
Loading