https://github.com/gr2m/octoherd-script-bump-node-version-in-workflows
Octoherd script to set the node-version input for actions/setup-node to the latest LTS major version
https://github.com/gr2m/octoherd-script-bump-node-version-in-workflows
octoherd-script
Last synced: about 1 month ago
JSON representation
Octoherd script to set the node-version input for actions/setup-node to the latest LTS major version
- Host: GitHub
- URL: https://github.com/gr2m/octoherd-script-bump-node-version-in-workflows
- Owner: gr2m
- License: isc
- Created: 2021-09-17T21:30:40.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-08T00:38:57.000Z (over 2 years ago)
- Last Synced: 2025-04-22T04:05:32.256Z (about 1 month ago)
- Topics: octoherd-script
- Language: JavaScript
- Size: 25.4 KB
- Stars: 4
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-octoherd-scripts - Bump Node version in workflows - Set the node-version input for actions/setup-node to the latest LTS major version. (Scripts)
README
# octoherd-script-bump-node-version-in-workflows
> Octoherd script to set the node-version input for actions/setup-node to the latest LTS major version
[](https://www.npmjs.com/package/octoherd-script-bump-node-version-in-workflows)
[](https://github.com/gr2m/octoherd-script-bump-node-version-in-workflows/actions?query=workflow%3ATest+branch%3Amain)## Usage
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)
Minimal usage
```js
npx octoherd-script-bump-node-version-in-workflows -T ghp_0123456789abcdefghjklmnopqrstuvwxyzA
```Pass all options as CLI flags to avoid user prompts
```js
npx octoherd-script-bump-node-version-in-workflows@latest \
-T ghp_0123456789abcdefghjklmnopqrstuvwxyzA \
-R "gr2m/*" \
--node-version "lts/*" \
--workflow release.yml
```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 serializing using `js-yaml` **removes all comments**. But the script will only update a file if a node-version was actually changed.
If `node-version` is set to a value which includes a `${{ ... }}` placeholder then it's not updated.
I run the script against all [@octokit repositories](https://github.com/orgs/octokit/repositories) so I'm fairly confident it doesn't break anything.
## Options
| option | type | description |
| ---------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--node-version` | number | **Required** May be set to `lts/*`. See [all supported versions](https://github.com/actions/setup-node#supported-version-syntax) |
| `--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 `*` |
| `--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 |
| `--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 |
| `--octoherd-bypass-confirms` | boolean | Bypass prompts to confirm mutating requests |## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md)
## About Octoherd
[@octoherd](https://github.com/octoherd/) is project to help you keep your GitHub repositories in line.
## License
[ISC](LICENSE.md)