Skip to content

Commit c6d37f6

Browse files
committed
Generate documentation from actions.yml
Right now the documentation of valid inputs (and outputs) seems to be manually maintained inside the `README.md` with a reference to the `actions.yml` file. Since this can be rather tedious to maintain this commit now uses [github-actions-docs][1] to automatically generate documentation. [1]: https://www.npmjs.com/package/github-action-docs
1 parent 8026329 commit c6d37f6

File tree

3 files changed

+69
-63
lines changed

3 files changed

+69
-63
lines changed

README.md

+28-62
Original file line numberDiff line numberDiff line change
@@ -16,68 +16,34 @@ This action provides the following functionality for GitHub Actions users:
1616

1717
See [action.yml](action.yml)
1818

19-
<!-- start usage -->
20-
```yaml
21-
- uses: actions/setup-node@v4
22-
with:
23-
# Version Spec of the version to use in SemVer notation.
24-
# It also admits such aliases as lts/*, latest, nightly and canary builds
25-
# Examples: 12.x, 10.15.1, >=10.15.0, lts/Hydrogen, 16-nightly, latest, node
26-
node-version: ''
27-
28-
# File containing the version Spec of the version to use. Examples: package.json, .nvmrc, .node-version, .tool-versions.
29-
# If node-version and node-version-file are both provided the action will use version from node-version.
30-
node-version-file: ''
31-
32-
# Set this option if you want the action to check for the latest available version
33-
# that satisfies the version spec.
34-
# It will only get affect for lts Nodejs versions (12.x, >=10.15.0, lts/Hydrogen).
35-
# Default: false
36-
check-latest: false
37-
38-
# Target architecture for Node to use. Examples: x86, x64. Will use system architecture by default.
39-
# Default: ''. The action use system architecture by default
40-
architecture: ''
41-
42-
# Used to pull node distributions from https://github.com/actions/node-versions.
43-
# Since there's a default, this is typically not supplied by the user.
44-
# When running this action on github.com, the default value is sufficient.
45-
# When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting.
46-
#
47-
# We recommend using a service account with the least permissions necessary. Also
48-
# when generating a new PAT, select the least scopes necessary.
49-
#
50-
# [Learn more about creating and using encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)
51-
#
52-
# Default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
53-
token: ''
54-
55-
# Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm.
56-
# Package manager should be pre-installed
57-
# Default: ''
58-
cache: ''
59-
60-
# Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc.
61-
# It will generate hash from the target file for primary key. It works only If cache is specified.
62-
# Supports wildcards or a list of file names for caching multiple dependencies.
63-
# Default: ''
64-
cache-dependency-path: ''
65-
66-
# Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file,
67-
# and set up auth to read in from env.NODE_AUTH_TOKEN.
68-
# Default: ''
69-
registry-url: ''
70-
71-
# Optional scope for authenticating against scoped registries.
72-
# Will fall back to the repository owner when using the GitHub Packages registry (https://npm.pkg.github.com/).
73-
# Default: ''
74-
scope: ''
75-
76-
# Set always-auth option in npmrc file.
77-
# Default: ''
78-
always-auth: ''
79-
```
80-
<!-- end usage -->
19+
<!-- markdownlint-capture -->
20+
<!-- markdownlint-disable -->
21+
<!-- prettier-ignore-start -->
22+
<!-- BEGIN_GITHUB_ACTION_DOCS -->
23+
## Inputs
24+
25+
| Name | Description | Default | Required |
26+
|------|-------------|---------|:--------:|
27+
| <a name="input_always_auth"></a> [always-auth](#input\_always\_auth) | Set always-auth in npmrc. | `false` | no |
28+
| <a name="input_architecture"></a> [architecture](#input\_architecture) | Target architecture for Node to use. Examples: x86, x64. Will use system architecture by default. | | no |
29+
| <a name="input_cache"></a> [cache](#input\_cache) | Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm. | | no |
30+
| <a name="input_cache_dependency_path"></a> [cache-dependency-path](#input\_cache\_dependency\_path) | Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc. Supports wildcards or a list of file names for caching multiple dependencies. | | no |
31+
| <a name="input_check_latest"></a> [check-latest](#input\_check\_latest) | Set this option if you want the action to check for the latest available version that satisfies the version spec. | | no |
32+
| <a name="input_node_version"></a> [node-version](#input\_node\_version) | Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0. | | no |
33+
| <a name="input_node_version_file"></a> [node-version-file](#input\_node\_version\_file) | File containing the version Spec of the version to use. Examples: package.json, .nvmrc, .node-version, .tool-versions. | | no |
34+
| <a name="input_registry_url"></a> [registry-url](#input\_registry\_url) | Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file, and set up auth to read in from env.NODE_AUTH_TOKEN. | | no |
35+
| <a name="input_scope"></a> [scope](#input\_scope) | Optional scope for authenticating against scoped registries. Will fall back to the repository owner when using the GitHub Packages registry (https://npm.pkg.github.com/). | | no |
36+
| <a name="input_token"></a> [token](#input\_token) | Used to pull node distributions from node-versions. Since there's a default, this is typically not supplied by the user. When running this action on github.com, the default value is sufficient. When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting. | `${{ github.server_url == 'https://github.com' && github.token || '' }}` | no |
37+
38+
## Outputs
39+
40+
| Name | Description |
41+
|------|-------------|
42+
| <a name="output_cache_hit"></a> [cache-hit](#output\_cache\_hit) | A boolean value to indicate if a cache was hit. |
43+
| <a name="output_node_version"></a> [node-version](#output\_node\_version) | The installed node version. |
44+
<!-- END_GITHUB_ACTION_DOCS -->
45+
<!-- prettier-ignore-end -->
46+
<!-- markdownlint-restore -->
8147

8248
**Basic:**
8349

package-lock.json

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

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"lint": "eslint --config ./.eslintrc.js \"**/*.ts\"",
1212
"lint:fix": "eslint --config ./.eslintrc.js \"**/*.ts\" --fix",
1313
"test": "jest --coverage",
14-
"pre-checkin": "npm run format && npm run lint:fix && npm run build && npm test"
14+
"pre-checkin": "npm run gen-docs && npm run format && npm run lint:fix && npm run build && npm test",
15+
"gen-docs": "github-action-docs --sections inputs outputs --output-file README.md --mode inject action.yml"
1516
},
1617
"repository": {
1718
"type": "git",
@@ -47,6 +48,7 @@
4748
"eslint-config-prettier": "^8.6.0",
4849
"eslint-plugin-jest": "^27.9.0",
4950
"eslint-plugin-node": "^11.1.0",
51+
"github-action-docs": "^1.1.0",
5052
"jest": "^29.7.0",
5153
"jest-circus": "^29.7.0",
5254
"jest-each": "^29.7.0",

0 commit comments

Comments
 (0)