|
1 |
| -# 🚧 WORK IN PROGRESS. See [#1](https://github.com/gr2m/octoherd-script-bump-node-version-in-workflows/pull/1) | [Preview](https://github.com/gr2m/octoherd-script-bump-node-version-in-workflows/tree/initial-version) |
2 |
| - |
3 | 1 | # octoherd-script-bump-node-version-in-workflows
|
4 | 2 |
|
5 | 3 | > Octoherd script to set the node-version input for actions/setup-node to the latest LTS major version
|
6 | 4 |
|
| 5 | +[](https://www.npmjs.com/package/octoherd-script-bump-node-version-in-workflows) |
| 6 | +[](https://github.com/gr2m/octoherd-script-bump-node-version-in-workflows/actions?query=workflow%3ATest+branch%3Amain) |
| 7 | + |
| 8 | +## Usage |
| 9 | + |
| 10 | +Note: You **must** set a custom token for this script because it requires the `workflow` scope. [Create a token here](https://github.com/settings/tokens/new?scopes=workflow,repo&description=octoherd-script-bump-node-version-in-workflows) |
| 11 | + |
| 12 | +Minimal usage |
| 13 | + |
| 14 | +```js |
| 15 | +npx octoherd-script-bump-node-version-in-workflows -T ghp_0123456789abcdefghjklmnopqrstuvwxyzA |
| 16 | +``` |
| 17 | + |
| 18 | +Pass all options as CLI flags to avoid user prompts |
| 19 | + |
| 20 | +```js |
| 21 | +npx octoherd-script-bump-node-version-in-workflows \ |
| 22 | + -T ghp_0123456789abcdefghjklmnopqrstuvwxyzA \ |
| 23 | + -R "gr2m/*" \ |
| 24 | + --version 16 \ |
| 25 | + --workflow release.yml |
| 26 | +``` |
| 27 | + |
| 28 | +The script uses [`js-yaml`](https://github.com/nodeca/js-yaml), so the updated YAML code might also include **formatting changes**. Unfortunately the parsing and then searializing using `js-yaml` **removes all comments**. But the script will only update a file if a node-version was actually changed. |
| 29 | + |
| 30 | +If `node-version` is set to a value which includes a `${{ ... }}` placeholder then it's not updated. |
| 31 | + |
| 32 | +I run the script against all [@octokit repositories](https://github.com/orgs/octokit/repositories) so I'm fairly confident it doesn't break anything. |
| 33 | + |
| 34 | +## Options |
| 35 | + |
| 36 | +| option | type | description | |
| 37 | +| ---------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 38 | +| `--version` | number | Defaults to latest Node LTS major version | |
| 39 | +| `--workflow` | string | workflow file name or pattern to only update a subset of workflows. [matcher](https://github.com/sindresorhus/matcher#usage) is used for matching. Defaults to `*` | |
| 40 | +| `--octoherd-token`, `-T` | string | A personal access token ([create](https://github.com/settings/tokens/new?scopes=repo)). Script will create one if option is not set | |
| 41 | +| `--octoherd-repos`, `-R` | array of strings | One or multiple space-separated repositories in the form of `repo-owner/repo-name`. `repo-owner/*` will find all repositories for one owner. `*` will find all repositories the user has access to. Will prompt for repositories if not set | |
| 42 | +| `--octoherd-bypass-confirms` | boolean | Bypass prompts to confirm mutating requests | |
| 43 | + |
7 | 44 | ## Contributing
|
8 | 45 |
|
9 | 46 | See [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
0 commit comments