{"id":13485000,"url":"https://github.com/technote-space/toc-generator","last_synced_at":"2025-04-04T22:07:43.313Z","repository":{"id":40944444,"uuid":"205223888","full_name":"technote-space/toc-generator","owner":"technote-space","description":"GitHub Actions to generate TOC (Table of Contents)","archived":false,"fork":false,"pushed_at":"2023-05-09T04:00:33.000Z","size":30446,"stargazers_count":232,"open_issues_count":6,"forks_count":29,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-01T04:01:58.361Z","etag":null,"topics":["github-actions","toc"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/technote-space.png","metadata":{"files":{"readme":"README.ja.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":"https://paypal.me/technote0space"}},"created_at":"2019-08-29T18:13:39.000Z","updated_at":"2025-03-18T01:58:59.000Z","dependencies_parsed_at":"2024-06-18T12:17:05.858Z","dependency_job_id":"9950030b-d4cd-42e3-b865-83529517b141","html_url":"https://github.com/technote-space/toc-generator","commit_stats":{"total_commits":844,"total_committers":7,"mean_commits":"120.57142857142857","dds":0.4158767772511849,"last_synced_commit":"3ba472e2cc699e92e6dba3f5ce758e1cde43fbc9"},"previous_names":[],"tags_count":195,"template":false,"template_full_name":"technote-space/gh-actions-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technote-space%2Ftoc-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technote-space%2Ftoc-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technote-space%2Ftoc-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technote-space%2Ftoc-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/technote-space","download_url":"https://codeload.github.com/technote-space/toc-generator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247256112,"owners_count":20909240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github-actions","toc"],"created_at":"2024-07-31T17:01:42.162Z","updated_at":"2025-04-04T22:07:43.295Z","avatar_url":"https://github.com/technote-space.png","language":"TypeScript","funding_links":["https://paypal.me/technote0space"],"categories":["TypeScript","Table of Contents","Community Resources","GitHub Actions"],"sub_categories":["Utility"],"readme":"# TOC Generator\n\n[![CI Status](https://github.com/technote-space/toc-generator/workflows/CI/badge.svg)](https://github.com/technote-space/toc-generator/actions)\n[![codecov](https://codecov.io/gh/technote-space/toc-generator/branch/main/graph/badge.svg)](https://codecov.io/gh/technote-space/toc-generator)\n[![CodeFactor](https://www.codefactor.io/repository/github/technote-space/toc-generator/badge)](https://www.codefactor.io/repository/github/technote-space/toc-generator)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/technote-space/toc-generator/blob/main/LICENSE)\n\n*Read this in other languages: [English](README.md), [日本語](README.ja.md).*\n\nこれは目次を生成する`GitHub Actions`です。  \n[DocToc](https://github.com/thlorenz/doctoc) を実行し変更があればコミットします。  \n\n## Table of Contents\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\u003cdetails\u003e\n\u003csummary\u003eDetails\u003c/summary\u003e\n\n- [インストール](#%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB)\n- [スクリーンショット](#%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88)\n- [オプション](#%E3%82%AA%E3%83%97%E3%82%B7%E3%83%A7%E3%83%B3)\n  - [個別に指定](#%E5%80%8B%E5%88%A5%E3%81%AB%E6%8C%87%E5%AE%9A)\n- [Action イベント詳細](#action-%E3%82%A4%E3%83%99%E3%83%B3%E3%83%88%E8%A9%B3%E7%B4%B0)\n  - [対象イベント](#%E5%AF%BE%E8%B1%A1%E3%82%A4%E3%83%99%E3%83%B3%E3%83%88)\n  - [Conditions](#conditions)\n- [補足](#%E8%A3%9C%E8%B6%B3)\n  - [GITHUB_TOKEN](#github_token)\n  - [プルリクエストの作成](#%E3%83%97%E3%83%AB%E3%83%AA%E3%82%AF%E3%82%A8%E3%82%B9%E3%83%88%E3%81%AE%E4%BD%9C%E6%88%90)\n  - [Context variables](#context-variables)\n  - [Context PR variables](#context-pr-variables)\n- [設定例](#%E8%A8%AD%E5%AE%9A%E4%BE%8B)\n  - [例１](#%E4%BE%8B%EF%BC%91)\n  - [例２](#%E4%BE%8B%EF%BC%92)\n  - [例３](#%E4%BE%8B%EF%BC%93)\n- [Author](#author)\n\n\u003c/details\u003e\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n## インストール\n1. 目次の位置を指定 (option)  \n   ```markdown\n   \u003c!-- START doctoc --\u003e\n   \u003c!-- END doctoc --\u003e\n   ```\n   [詳細](https://github.com/thlorenz/doctoc#specifying-location-of-toc)  \n1. workflow を設定  \n   例：`.github/workflows/toc.yml`\n   ```yaml\n   on: push\n   name: TOC Generator\n   jobs:\n     generateTOC:\n       name: TOC Generator\n       runs-on: ubuntu-latest\n       steps:\n         - uses: technote-space/toc-generator@v4\n   ```\n\n## スクリーンショット\n![behavior](https://raw.githubusercontent.com/technote-space/toc-generator/images/screenshot.gif)\n\n## オプション\n| name | description | default | e.g. |\n|:---|:---|:---|:---|\n|TARGET_PATHS|対象のファイルパス (カンマ区切り, [詳細](https://github.com/thlorenz/doctoc#adding-toc-to-individual-files))|`README*.md`|`README*.md,CHANGELOG.md`, `.`|\n|TOC_TITLE|目次タイトル|`**Table of Contents**`|`''`|\n|MAX_HEADER_LEVEL|Heading最大レベル ([詳細](https://github.com/thlorenz/doctoc#specifying-a-maximum-heading-level-for-toc-entries))| |`3`|\n|CUSTOM_MODE|Customモードかどうか([生成例](samples/README.horizontal.md))|`false`|`true`|\n|CUSTOM_TEMPLATE|Customテンプレート(Customモード)|`\u003cp align=\"center\"\u003e${ITEMS}\u003c/p\u003e`| |\n|ITEM_TEMPLATE|アイテムテンプレート(Customモード)|`\u003ca href=\"${LINK}\"\u003e${TEXT}\u003c/a\u003e`| |\n|SEPARATOR|セパレータ(Customモード)|\u003ccode\u003e\\\u003cspan\u003e\u0026#124;\\\u003c/span\u003e\u003c/code\u003e| |\n|FOLDING|目次を折りたたみ式にするかどうか|`false`|`true`|\n|COMMIT_MESSAGE|コミットメッセージ|`chore(docs): update TOC`|`docs: update TOC`|\n|COMMIT_NAME|コミット時に設定する名前|`${github.actor}`| |\n|COMMIT_EMAIL|コミット時に設定するメールアドレス|`${github.actor}@users.noreply.github.com`| |\n|CREATE_PR|プルリクエストを作成するかどうか|`false`|`true`|\n|CHECK_ONLY_DEFAULT_BRANCH|デフォルトのブランチのみをチェックするかどうか|`false`|`true`|\n|PR_BRANCH_PREFIX|プルリクエストのブランチプリフィックス|`toc-generator/`| |\n|PR_BRANCH_NAME|プルリクエストのブランチ名\u003cbr\u003e[Context variables](#context-variables)|`update-toc-${PR_ID}`|`toc-${PR_NUMBER}`|\n|PR_TITLE|プルリクエストのタイトル\u003cbr\u003e[Context variables](#context-variables)|`chore(docs): update TOC (${PR_MERGE_REF})`|`docs: update TOC`|\n|PR_BODY|プルリクエストの本文\u003cbr\u003e[Context PR variables](#context-pr-variables)|[action.yml](action.yml)| |\n|PR_COMMENT_BODY|プルリクエストの本文(コメント用)\u003cbr\u003e[Context PR variables](#context-pr-variables)|[action.yml](action.yml)| |\n|PR_CLOSE_MESSAGE|プルリクエストを閉じるときのメッセージ|`This PR has been closed because it is no longer needed.`| |\n|TARGET_BRANCH_PREFIX|ブランチ名のフィルタ| |`release/`|\n|INCLUDE_LABELS|プルリクエストに付与されているかチェックするラベル| |`Label1, Label2`|\n|OPENING_COMMENT|開始コメント (DocToc以外のため)|`\u003c!-- toc `| |\n|CLOSING_COMMENT|終了コメント (DocToc以外のため)|`\u003c!-- tocstop `| |\n|SKIP_COMMENT|スキップコメントを変更 (default: `\u003c!-- DOCTOC SKIP `)| |`\u003c!-- toc skip `|\n|GITHUB_TOKEN|アクセストークン|`${{github.token}}`|`${{secrets.ACCESS_TOKEN}}`|\n|SIGNOFF| Signed-off-byを付与 | |`true`|\n\n### 個別に指定\n[doctoc](https://github.com/technote-space/doctoc#example) に使用されているオプションはコメントで値を指定することが可能です。  \n異なる設定で複数の目次を生成したい場合は以下のように個別に値を指定してください。\n\n例： \n```markdown\n\u003c!-- START doctoc --\u003e\n\u003c!-- param::isNotitle::true:: --\u003e\n\u003c!-- param::isCustomMode::true:: --\u003e\n\n\u003c!-- END doctoc --\u003e\n\n...\n\n```\n\n## Action イベント詳細\n### 対象イベント\n| eventName: action | condition |\n|:---|:---|\n|push: *|[condition1](#condition1)|\n|pull_request: \\[opened, synchronize, reopened, labeled, unlabeled]|[condition2](#condition2)|\n|pull_request: \\[closed]||\n|schedule, repository_dispatch, workflow_dispatch||\n\n- 次のアクティビティタイプは明示的に指定する必要があります。 ([詳細](https://help.github.com/ja/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#pull-request-event-pull_request))\n  - `labeled`, `unlabeled`, `closed`\n### Conditions\n#### condition1\n- ブランチへのプッシュ (タグのプッシュではない)\n  - ブランチ名 ([`TARGET_BRANCH_PREFIX`](#%E3%82%AA%E3%83%97%E3%82%B7%E3%83%A7%E3%83%B3))\n#### condition2\n- 指定したラベルが付与されているかどうか ([`INCLUDE_LABELS`](#%E3%82%AA%E3%83%97%E3%82%B7%E3%83%A7%E3%83%B3))\n- ブランチ名 ([`TARGET_BRANCH_PREFIX`](#%E3%82%AA%E3%83%97%E3%82%B7%E3%83%A7%E3%83%B3))\n\n## 補足\n### GITHUB_TOKEN\nGitHub Actions で提供される`GITHUB_TOKEN`は連続するイベントを作成する権限がありません。  \nしたがって、プッシュによってトリガーされるビルドアクションなどは実行されません。  \n\nこれはブランチプロテクションを設定していると問題になる場合があります。  \n\nもしアクションをトリガーしたい場合は代わりに`personal access token`を使用してください。  \n1. public_repo または repo の権限で [Personal access token](https://help.github.com/ja/articles/creating-a-personal-access-token-for-the-command-line) を生成  \n(repo はプライベートリポジトリで必要です)  \n1. [ACCESS_TOKENとして保存](https://help.github.com/ja/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets)\n1. `GITHUB_TOKEN`の代わりに`ACCESS_TOKEN`を使用するように設定  \n   例：`.github/workflows/toc.yml`\n   ```yaml\n   on: push\n   name: TOC Generator\n   jobs:\n     generateTOC:\n       name: TOC Generator\n       runs-on: ubuntu-latest\n       steps:\n         - uses: technote-space/toc-generator@v4\n           with:\n             GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}\n   ```\n\n### プルリクエストの作成\n`CREATE_PR` に `true` を設定した場合は、プルリクエストが作成されます。  \n\n```yaml\non: pull_request\nname: TOC Generator\njobs:\n  generateTOC:\n    name: TOC Generator\n    runs-on: ubuntu-latest\n    steps:\n      - uses: technote-space/toc-generator@v4\n        with:\n          CREATE_PR: true\n```\n\n![create pr](https://raw.githubusercontent.com/technote-space/toc-generator/images/create_pr.png)\n\n`closed`アクティビティタイプが設定されている場合、このアクションは不要になったプルリクエストを閉じます。\n\n```yaml\non:\n  pull_request:\n    types: [opened, synchronize, reopened, closed]\nname: TOC Generator\njobs:\n  generateTOC:\n    name: TOC Generator\n    runs-on: ubuntu-latest\n    steps:\n      - uses: technote-space/toc-generator@v4\n```\n\n### Context variables\n| name | description |\n|:---|:---|\n| PR_NUMBER | pull_request.number (例：`11`) |\n| PR_NUMBER_REF | `#${pull_request.number}` (例：`#11`) |\n| PR_ID | pull_request.id (例：`21031067`) |\n| PR_HEAD_REF | pull_request.head.ref (例：`change`) |\n| PR_BASE_REF | pull_request.base.ref (例：`main`) |\n| PR_MERGE_REF | pull_request.base.ref (例：`change -\u003e main`) |\n| PR_TITLE | pull_request.title (例：`update the README with new information.`) |\n\n[Payload example](https://developer.github.com/v3/activity/events/types/#webhook-payload-example-28)\n\n### Context PR variables\n- [Context variables](#context-variables)\n\n| name | description |\n|:---|:---|\n| PR_LINK | プルリクエストへのリンク |\n| COMMANDS_OUTPUT | TOC コマンドの結果 |\n| FILES_SUMMARY | 例：`Changed 2 files` |\n| FILES | 変更されたファイル一覧 |\n\n## 設定例\n### 例１\nブランチを制限しないでPush時にアクションを実行し直接コミット\n\n```yaml\non: push\nname: TOC Generator\njobs:\n  generateTOC:\n    name: TOC Generator\n    runs-on: ubuntu-latest\n    steps:\n      - uses: technote-space/toc-generator@v4\n```\n\n### 例２\n`release/` から始まるブランチのみを対象にPull Request更新時に実行しPull Requestを作成または更新\n\n```yaml\non:\n  pull_request:\n    types: [opened, synchronize, reopened, closed]\nname: TOC Generator\njobs:\n  generateTOC:\n    name: TOC Generator\n    runs-on: ubuntu-latest\n    steps:\n      - uses: technote-space/toc-generator@v4\n        with:\n          CREATE_PR: true\n          TARGET_BRANCH_PREFIX: release/\n```\n\n### 例３\nデフォルトブランチのみを対象にスケジュールでアクションを実行し直接コミット  \n（他のワークフローの起動のために作成したTokenを使用）\n\n```yaml\non:\n  schedule:\n    - cron: \"0 23 * * *\"\nname: TOC Generator\njobs:\n  generateTOC:\n    name: TOC Generator\n    runs-on: ubuntu-latest\n    steps:\n      - uses: technote-space/toc-generator@v4\n        with:\n          GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}\n          CHECK_ONLY_DEFAULT_BRANCH: true\n```\n\n## Author\n[GitHub (Technote)](https://github.com/technote-space)  \n[Blog](https://technote.space)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechnote-space%2Ftoc-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechnote-space%2Ftoc-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechnote-space%2Ftoc-generator/lists"}