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

OPSEXP-2939: add a markdown toc generation action #825

Merged
merged 21 commits into from
Dec 6, 2024
Merged
57 changes: 57 additions & 0 deletions .github/actions/simple-md-toc/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#Github Composite actions to generate Markdown Table of Contents
gionn marked this conversation as resolved.
Show resolved Hide resolved
name: Simple Markdown ToC Generator
alxgomz marked this conversation as resolved.
Show resolved Hide resolved
description: Generate a Table of Contents from a Markdown file
inputs:
md_toc_version:
description: Markdown Table of Contents Package version
required: false
default: 1.2.0
md_src:
description: Markdown file to generate Table of Contents
required: true
gionn marked this conversation as resolved.
Show resolved Hide resolved
depth:
description: Depth of Table of Contents
required: false
default: '2'
dry_run:
description: Skip destructive actions
required: false
default: 'false'
gionn marked this conversation as resolved.
Show resolved Hide resolved
append:
description: Append to Table of Contents
alxgomz marked this conversation as resolved.
Show resolved Hide resolved
required: false
default: ''
bullets:
description: Bullets to use for Table of Contents ("*", "-" or "+")
required: false
default: '*'
node_install:
description: Node.js installation should be skipped if done already before in calling wf
required: false
default: 'true'
alxgomz marked this conversation as resolved.
Show resolved Hide resolved
runs:
using: 'composite'
steps:
- uses: actions/setup-node@v4
if: ${{ inputs.node_install }}
with:
node-version: 20
- name: Install Markdown ToC node package
run: npm install -g markdown-toc@${{ inputs.md_toc_version }}
shell: bash
- name: Generate Table of Contents
env:
MDTOC_IARG: ${{ inputs.dry_run == 'false' && '-i' || '' }}
run: |
markdown-toc "$MDTOC_IARG" \
--maxdepth "${{ inputs.depth }}" \
--bullets "${{ inputs.bullets }}" \
--append "${{ inputs.append }}" \
${{ inputs.md_src }} && \
echo "Table of Contents successfully generated in ${{ inputs.md_src }}"
shell: bash
- name: Autocommit changes
if: inputs.dry_run == 'false'
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Auto update TOC in ${{ inputs.md_src }}
alxgomz marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,14 @@ updates:
catch-all:
patterns:
- "*"
- package-ecosystem: "github-actions"
directory: "/.github/actions/simple-md-toc"
schedule:
interval: "weekly"
groups:
catch-all:
patterns:
- "*"
- package-ecosystem: "github-actions"
directory: "/.github/actions/slack-file-upload"
schedule:
Expand Down
21 changes: 21 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ Here follows the list of GitHub Actions topics available in the current document
- [setup-terraform-docs](#setup-terraform-docs)
- [setup-updatebot](#setup-updatebot)
- [slack-file-upload](#slack-file-upload)
- [simple-md-toc](#simple-md-toc)
- [update-deployment-runtime-versions](#update-deployment-runtime-versions)
- [update-pom-to-next-pre-release](#update-pom-to-next-pre-release)
- [update-project-base-tag](#update-project-base-tag)
Expand Down Expand Up @@ -1663,6 +1664,26 @@ Uploads a file to a Slack channel.
file-title: 'file description' # optional
```

### simple-md-toc

Generates a Markdown table of contents for a file.

```yaml
- uses: Alfresco/alfresco-build-tools/.github/actions/simple-md-toc@ref
with:
md_src: 'docs/README.md'
bullets: '-'
depth: '4'
md_toc_version: 1.2.0
node_install: 'false'
```

For ToC to be inserted in your file, it needs to contain the HTML comment below:

```markdown
<!-- toc -->
```

### update-deployment-runtime-versions

For more information, see [update-deployment-runtime-versions](../.github/actions/update-deployment-runtime-versions/action.yml).
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v8.4.0
v8.5.0
Loading