# TOC Generator [![CI Status](https://github.com/technote-space/toc-generator/workflows/CI/badge.svg)](https://github.com/technote-space/toc-generator/actions) [![codecov](https://codecov.io/gh/technote-space/toc-generator/branch/master/graph/badge.svg)](https://codecov.io/gh/technote-space/toc-generator) [![CodeFactor](https://www.codefactor.io/repository/github/technote-space/toc-generator/badge)](https://www.codefactor.io/repository/github/technote-space/toc-generator) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/technote-space/toc-generator/blob/master/LICENSE) *Read this in other languages: [English](README.md), [日本語](README.ja.md).* This is a `GitHub Actions` to generate TOC (Table of Contents), which executes [DocToc](https://github.com/thlorenz/doctoc) and commits if changed.

Installation | Screenshot | Options | Action event details | Addition | Configuration Examples | Author

## Installation 1. Specify location of TOC (option) e.g. `README.md` ```markdown ``` [detail](https://github.com/thlorenz/doctoc#specifying-location-of-toc) 1. Setup workflow e.g. `.github/workflows/toc.yml` ```yaml on: push name: TOC Generator jobs: generateTOC: name: TOC Generator runs-on: ubuntu-latest steps: - uses: technote-space/toc-generator@v3 ``` ## Screenshot ![behavior](https://raw.githubusercontent.com/technote-space/toc-generator/images/screenshot.gif) ## Options | name | description | default | required | e.g. | |:---:|:---|:---:|:---:|:---:| |TARGET_PATHS|Target file path. (Comma separated, [Detail](https://github.com/thlorenz/doctoc#adding-toc-to-individual-files))|`README*.md`|true|`README*.md,CHANGELOG.md`, `.`| |TOC_TITLE|TOC Title|`**Table of Contents**`| |`''`| |MAX_HEADER_LEVEL|Maximum heading level. ([Detail](https://github.com/thlorenz/doctoc#specifying-a-maximum-heading-level-for-toc-entries))| | |`3`| |CUSTOM_MODE|Whether it is custom mode([Generated Example](./__tests__/fixtures/doctoc/expected/README.horizontal2.md))|`false`| |`true`| |CUSTOM_TEMPLATE|Custom template for custom mode|`

${ITEMS}

`| | | |ITEM_TEMPLATE|Item template for custom mode|`${TEXT}`| | | |SEPARATOR|Separator for custom mode|\|\| | | |FOLDING|Whether to make TOC foldable([Generated Example](./__tests__/fixtures/doctoc/expected/README.update.wrap.md))|`false`| |`true`| |COMMIT_MESSAGE|Commit message|`chore(docs): update TOC`|true|`docs: update TOC`| |COMMIT_NAME|Git commit name|`${github.actor}`| | | |COMMIT_EMAIL|Git commit email|`${github.actor}@users.noreply.github.com`| | | |CREATE_PR|Whether to check only default branch|`false`| |`true`| |CHECK_ONLY_DEFAULT_BRANCH|Whether to create PullRequest|`false`| |`true`| |PR_BRANCH_PREFIX|PullRequest branch prefix|`toc-generator/`|true| | |PR_BRANCH_NAME|PullRequest branch name
[Context variables](#context-variables)|`update-toc-${PR_ID}`|true|`toc-${PR_NUMBER}`| |PR_TITLE|PullRequest title
[Context variables](#context-variables)|`chore(docs): update TOC (${PR_MERGE_REF})`|true|`docs: update TOC`| |PR_BODY|PullRequest body
[Context PR variables](#context-pr-variables)|[action.yml](action.yml)|true| | |PR_COMMENT_BODY|PullRequest body for comment
[Context PR variables](#context-pr-variables)|[action.yml](action.yml)| | | |PR_CLOSE_MESSAGE|Message body when closing PullRequest|`This PR has been closed because it is no longer needed.`| | | |TARGET_BRANCH_PREFIX|Filter by branch name| | |`release/`| |INCLUDE_LABELS|Labels used to check if the PullRequest has it| | |`Label1, Label2`| |OPENING_COMMENT|Opening comment (for other than DocToc)|`