Skip to content

Commit

Permalink
feat!: add support to update header based on action name (#425)
Browse files Browse the repository at this point in the history
* feat: add support to update header based on action name

* chore(ci): Updating dist and docs

* fix readme

* chore(ci): Updating dist and docs

* headers

* headers

* chore(ci): Updating dist and docs

* headers

* headers

* chore(ci): Updating dist and docs

* headers

* chore(ci): Updating dist and docs
  • Loading branch information
npalm authored Feb 18, 2024
1 parent 9fa96f2 commit 8f05cb8
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 36 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
branches:
- main
pull_request:


jobs:
build:
Expand Down Expand Up @@ -34,8 +33,10 @@ jobs:
run: yarn build && yarn run package

- name: Update docs
uses: './'

uses: './'
with:
tocLevel: 1

- name: Update dist in the repository
if: github.ref != 'refs/heads/main'

Expand Down
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
<a href="https://github.com/npalm/action-docs-action/actions"><img alt="action-docs-action status" src="https://github.com/npalm/action-docs-action/actions/workflows/ci.yml/badge.svg"></a>
</p>

# Action to update action documentation <!-- omit in toc -->
<!-- action-docs-header action="action.yml" -->
# Action to update GitHub Action documentation
<!-- action-docs-header action="action.yml" -->

This action wraps [action-docs](https://github.com/npalm/action-docs) to update action documentation. By default the action will update `README.md` based on the the `action.yml`. See the parameters for changing the defaults.


## Usages

The action will update you readme by replacing html comment tags. Add one of more tags based on the following template to your repo: `<!-- action-docs-(description | inputs | outputs | runs -->` to add the corresponding section.
The action will update you readme by replacing html comment tags. Add one of more tags based on the following template to your repo: `<!-- action-docs-(header | description | inputs | outputs | runs -->` to add the corresponding section.

- `header` : to add/updae a header based on the name of the action
- `description` : to add/update a section with a descriptions of the action
- `inputs`: to add/update a section with inputs of the action
- `outputs`: to add/update a section with outputs of the action
Expand All @@ -32,20 +34,17 @@ The action will not commit any change, to ensure the changes are persisted you c
| --- | --- | --- | --- |
| `readme` | <p>Readme file to update.</p> | `false` | `README.md` |
| `actionFile` | <p>THe action definition file.</p> | `false` | `action.yml` |
| `tocLevel` | <p>TOC level used for the headers.</p> | `false` | `2` |
| `includeNameHeader` | <p>Include the name header in the updated readme.</p> | `false` | `true` |
| `tocLevel` | <p>TOC level used for the headers. The <code>includeNameHeader</code> input is influecing the TOC level, setting <code>includeNameHeader</code> to true will increase the TOC level by 1.</p> | `false` | `2` |
| `lineBreaks` | <p>Line breaks to be used in updated readme (LF|CR|CRLF).</p> | `false` | `LF` |
<!-- action-docs-inputs action="action.yml" -->

<!-- action-docs-inputs -->


<!-- action-docs-runs action="action.yml" -->
## Runs

This action is a `node20` action.
<!-- action-docs-runs action="action.yml" -->

<!-- action-docs-runs -->
## License

This project are released under the [MIT License](./LICENSE).
16 changes: 10 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'Action update docs action'
description: 'Action updates the action documentation.'
name: 'Action to update GitHub Action documentation'
description: 'Update docuemntation in the README file for a GitHub Action based on the action.yml.'
author: 'Niek Palm'

branding:
Expand All @@ -11,19 +11,23 @@ inputs:
description: 'Readme file to update.'
required: false
default: README.md
actionFile:
actionFile:
description: 'THe action definition file.'
required: false
default: action.yml
includeNameHeader:
description: 'Include the name header in the updated readme.'
required: false
default: true
tocLevel:
description: "TOC level used for the headers."
description: 'TOC level used for the headers. The `includeNameHeader` input is influecing the TOC level, setting `includeNameHeader` to true will increase the TOC level by 1.'
required: false
default: 2
lineBreaks:
description: "Line breaks to be used in updated readme (LF|CR|CRLF)."
description: 'Line breaks to be used in updated readme (LF|CR|CRLF).'
required: false
default: LF

runs:
using: 'node20'
main: 'dist/index.js'
main: 'dist/index.js'
29 changes: 23 additions & 6 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
"license": "MIT",
"dependencies": {
"@actions/core": "^1.10.0",
"action-docs": "^2.0.0"
"action-docs": "^2.1.0"
},
"devDependencies": {
"@types/node": "^20.11.16",
"@typescript-eslint/parser": "^6.21.0",
"@types/node": "^20.11.19",
"@typescript-eslint/parser": "^7.0.1",
"@vercel/ncc": "^0.38.1",
"eslint": "^8.37.0",
"eslint-plugin-github": "^4.6.1",
Expand Down
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ async function run(): Promise<void> {
const tocLevel: number = parseInt(core.getInput('tocLevel', { required: true }));
const actionFile: string = core.getInput('actionFile', { required: true });
const lineBreaks = core.getInput('lineBreaks', { required: true }) as 'LF' | 'CR' | 'CRLF';
const includeNameHeader = core.getInput('includeNameHeader', { required: true }) === 'true';

await generateActionMarkdownDocs({
actionFile,
readmeFile,
updateReadme: true,
tocLevel,
lineBreaks,
includeNameHeader,
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
Expand Down
64 changes: 55 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==

"@types/node@^20.11.16":
version "20.11.16"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.16.tgz#4411f79411514eb8e2926f036c86c9f0e4ec6708"
integrity sha512-gKb0enTmRCzXSSUJDq6/sPcqrfCv2mkkG6Jt/clpn5eiCbKTY+SgZUxo+p8ZKMof5dCp9vHQUAB7wOUTod22wQ==
"@types/node@^20.11.19":
version "20.11.19"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.19.tgz#b466de054e9cb5b3831bee38938de64ac7f81195"
integrity sha512-7xMnVEcZFu0DikYjWOlRq7NTPETrm7teqUT2WkQjrTIkEgUyyGdWsj/Zg8bEJt5TNklzbPD1X3fqfsHw3SpapQ==
dependencies:
undici-types "~5.26.4"

Expand Down Expand Up @@ -211,7 +211,7 @@
semver "^7.5.4"
ts-api-utils "^1.0.1"

"@typescript-eslint/parser@^6.0.0", "@typescript-eslint/parser@^6.21.0":
"@typescript-eslint/parser@^6.0.0":
version "6.21.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-6.21.0.tgz#af8fcf66feee2edc86bc5d1cf45e33b0630bf35b"
integrity sha512-tbsV1jPne5CkFQCgPBcDOt30ItF7aJoZL997JSF7MhGQqOeT3svWRYxiqlfA5RUdlHN6Fi+EI9bxqbdyAUZjYQ==
Expand All @@ -222,6 +222,17 @@
"@typescript-eslint/visitor-keys" "6.21.0"
debug "^4.3.4"

"@typescript-eslint/parser@^7.0.1":
version "7.0.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-7.0.1.tgz#e9c61d9a5e32242477d92756d36086dc40322eed"
integrity sha512-8GcRRZNzaHxKzBPU3tKtFNing571/GwPBeCvmAUw0yBtfE2XVd0zFKJIMSWkHJcPQi0ekxjIts6L/rrZq5cxGQ==
dependencies:
"@typescript-eslint/scope-manager" "7.0.1"
"@typescript-eslint/types" "7.0.1"
"@typescript-eslint/typescript-estree" "7.0.1"
"@typescript-eslint/visitor-keys" "7.0.1"
debug "^4.3.4"

"@typescript-eslint/scope-manager@6.21.0":
version "6.21.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-6.21.0.tgz#ea8a9bfc8f1504a6ac5d59a6df308d3a0630a2b1"
Expand All @@ -230,6 +241,14 @@
"@typescript-eslint/types" "6.21.0"
"@typescript-eslint/visitor-keys" "6.21.0"

"@typescript-eslint/scope-manager@7.0.1":
version "7.0.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-7.0.1.tgz#611ec8e78c70439b152a805e1b10aaac36de7c00"
integrity sha512-v7/T7As10g3bcWOOPAcbnMDuvctHzCFYCG/8R4bK4iYzdFqsZTbXGln0cZNVcwQcwewsYU2BJLay8j0/4zOk4w==
dependencies:
"@typescript-eslint/types" "7.0.1"
"@typescript-eslint/visitor-keys" "7.0.1"

"@typescript-eslint/type-utils@6.21.0":
version "6.21.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-6.21.0.tgz#6473281cfed4dacabe8004e8521cee0bd9d4c01e"
Expand All @@ -245,6 +264,11 @@
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.21.0.tgz#205724c5123a8fef7ecd195075fa6e85bac3436d"
integrity sha512-1kFmZ1rOm5epu9NZEZm1kckCDGj5UJEf7P1kliH4LKu/RkwpsfqqGmY2OOcUs18lSlQBKLDYBOGxRVtrMN5lpg==

"@typescript-eslint/types@7.0.1":
version "7.0.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-7.0.1.tgz#dcfabce192db5b8bf77ea3c82cfaabe6e6a3c901"
integrity sha512-uJDfmirz4FHib6ENju/7cz9SdMSkeVvJDK3VcMFvf/hAShg8C74FW+06MaQPODHfDJp/z/zHfgawIJRjlu0RLg==

"@typescript-eslint/typescript-estree@6.21.0":
version "6.21.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-6.21.0.tgz#c47ae7901db3b8bddc3ecd73daff2d0895688c46"
Expand All @@ -259,6 +283,20 @@
semver "^7.5.4"
ts-api-utils "^1.0.1"

"@typescript-eslint/typescript-estree@7.0.1":
version "7.0.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-7.0.1.tgz#1d52ac03da541693fa5bcdc13ad655def5046faf"
integrity sha512-SO9wHb6ph0/FN5OJxH4MiPscGah5wjOd0RRpaLvuBv9g8565Fgu0uMySFEPqwPHiQU90yzJ2FjRYKGrAhS1xig==
dependencies:
"@typescript-eslint/types" "7.0.1"
"@typescript-eslint/visitor-keys" "7.0.1"
debug "^4.3.4"
globby "^11.1.0"
is-glob "^4.0.3"
minimatch "9.0.3"
semver "^7.5.4"
ts-api-utils "^1.0.1"

"@typescript-eslint/utils@6.21.0":
version "6.21.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.21.0.tgz#4714e7a6b39e773c1c8e97ec587f520840cd8134"
Expand All @@ -280,6 +318,14 @@
"@typescript-eslint/types" "6.21.0"
eslint-visitor-keys "^3.4.1"

"@typescript-eslint/visitor-keys@7.0.1":
version "7.0.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-7.0.1.tgz#864680ac5a8010ec4814f8a818e57595f79f464e"
integrity sha512-hwAgrOyk++RTXrP4KzCg7zB2U0xt7RUU0ZdMSCsqF3eKUwkdXUMyTb0qdCuji7VIbcpG62kKTU9M1J1c9UpFBw==
dependencies:
"@typescript-eslint/types" "7.0.1"
eslint-visitor-keys "^3.4.1"

"@ungap/structured-clone@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.2.0.tgz#756641adb587851b5ccb3e095daf27ae581c8406"
Expand Down Expand Up @@ -310,10 +356,10 @@ acorn@^8.9.0:
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.3.tgz#71e0b14e13a4ec160724b38fb7b0f233b1b81d7a"
integrity sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==

action-docs@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/action-docs/-/action-docs-2.0.0.tgz#b1bd68296458473664ac9028160894a576b24d6c"
integrity sha512-AT46HljUncSwJQAF2cojGzpFKzth9eV11as1zSJ5KPp3un0yreFNEwYvr4Zwip37fR64szeGgLyNn8dOFgW1yg==
action-docs@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/action-docs/-/action-docs-2.1.0.tgz#f20c45094c2b92b2b16eab524075a113dd6b64a9"
integrity sha512-1XrMDfa/Su08K8BF64Rei7b3eylgi+1Bj40TL5tek52EEic3HZMtN97+iWcx+S9L+SL1oJYXZ9A6mQ5iICcQlw==
dependencies:
chalk "^5.3.0"
eslint-import-resolver-typescript "^3.6.1"
Expand Down

0 comments on commit 8f05cb8

Please sign in to comment.