4.3.1 • Published 1 year ago

@technote-space/toc-generator v4.3.1

Weekly downloads
31
License
MIT
Repository
github
Last release
1 year ago

TOC Generator

CI Status codecov CodeFactor License: MIT

Read this in other languages: English, 日本語.

これは目次を生成するGitHub Actionsです。
DocToc を実行し変更があればコミットします。

Table of Contents

インストール

  1. 目次の位置を指定 (option)
    <!-- START doctoc -->
    <!-- END doctoc -->
    詳細
  2. workflow を設定
    例:.github/workflows/toc.yml
    on: push
    name: TOC Generator
    jobs:
      generateTOC:
        name: TOC Generator
        runs-on: ubuntu-latest
        steps:
          - uses: technote-space/toc-generator@v4

スクリーンショット

behavior

オプション

namedescriptiondefaulte.g.
TARGET_PATHS対象のファイルパス (カンマ区切り, 詳細)README*.mdREADME*.md,CHANGELOG.md, .
TOC_TITLE目次タイトル**Table of Contents**''
MAX_HEADER_LEVELHeading最大レベル (詳細)3
CUSTOM_MODECustomモードかどうか(生成例)falsetrue
CUSTOM_TEMPLATECustomテンプレート(Customモード)<p align="center">${ITEMS}</p>
ITEM_TEMPLATEアイテムテンプレート(Customモード)<a href="${LINK}">${TEXT}</a>
SEPARATORセパレータ(Customモード)\|\
FOLDING目次を折りたたみ式にするかどうかfalsetrue
COMMIT_MESSAGEコミットメッセージchore(docs): update TOCdocs: update TOC
COMMIT_NAMEコミット時に設定する名前${github.actor}
COMMIT_EMAILコミット時に設定するメールアドレス${github.actor}@users.noreply.github.com
CREATE_PRプルリクエストを作成するかどうかfalsetrue
CHECK_ONLY_DEFAULT_BRANCHデフォルトのブランチのみをチェックするかどうかfalsetrue
PR_BRANCH_PREFIXプルリクエストのブランチプリフィックスtoc-generator/
PR_BRANCH_NAMEプルリクエストのブランチ名Context variablesupdate-toc-${PR_ID}toc-${PR_NUMBER}
PR_TITLEプルリクエストのタイトルContext variableschore(docs): update TOC (${PR_MERGE_REF})docs: update TOC
PR_BODYプルリクエストの本文Context PR variablesaction.yml
PR_COMMENT_BODYプルリクエストの本文(コメント用)Context PR variablesaction.yml
PR_CLOSE_MESSAGEプルリクエストを閉じるときのメッセージThis PR has been closed because it is no longer needed.
TARGET_BRANCH_PREFIXブランチ名のフィルタrelease/
INCLUDE_LABELSプルリクエストに付与されているかチェックするラベルLabel1, Label2
OPENING_COMMENT開始コメント (DocToc以外のため)<!-- toc
CLOSING_COMMENT終了コメント (DocToc以外のため)<!-- tocstop
SKIP_COMMENTスキップコメントを変更 (default: <!-- DOCTOC SKIP)<!-- toc skip
GITHUB_TOKENアクセストークン${{github.token}}${{secrets.ACCESS_TOKEN}}
SIGNOFFSigned-off-byを付与true

個別に指定

doctoc に使用されているオプションはコメントで値を指定することが可能です。
異なる設定で複数の目次を生成したい場合は以下のように個別に値を指定してください。

例:

<!-- START doctoc -->
<!-- param::isNotitle::true:: -->
<!-- param::isCustomMode::true:: -->

<!-- END doctoc -->

...

Action イベント詳細

対象イベント

eventName: actioncondition
push: *condition1
pull_request: [opened, synchronize, reopened, labeled, unlabeled]condition2
pull_request: [closed]
schedule, repository_dispatch, workflow_dispatch
  • 次のアクティビティタイプは明示的に指定する必要があります。 (詳細)
    • labeled, unlabeled, closed

Conditions

condition1

  • ブランチへのプッシュ (タグのプッシュではない)

condition2

補足

GITHUB_TOKEN

GitHub Actions で提供されるGITHUB_TOKENは連続するイベントを作成する権限がありません。
したがって、プッシュによってトリガーされるビルドアクションなどは実行されません。

これはブランチプロテクションを設定していると問題になる場合があります。

もしアクションをトリガーしたい場合は代わりにpersonal access tokenを使用してください。
1. public_repo または repo の権限で Personal access token を生成
(repo はプライベートリポジトリで必要です)
1. ACCESS_TOKENとして保存 1. GITHUB_TOKENの代わりにACCESS_TOKENを使用するように設定
例:.github/workflows/toc.yml

on: push
name: TOC Generator
jobs:
  generateTOC:
    name: TOC Generator
    runs-on: ubuntu-latest
    steps:
      - uses: technote-space/toc-generator@v4
        with:
          GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}

プルリクエストの作成

CREATE_PRtrue を設定した場合は、プルリクエストが作成されます。

on: pull_request
name: TOC Generator
jobs:
  generateTOC:
    name: TOC Generator
    runs-on: ubuntu-latest
    steps:
      - uses: technote-space/toc-generator@v4
        with:
          CREATE_PR: true

create pr

closedアクティビティタイプが設定されている場合、このアクションは不要になったプルリクエストを閉じます。

on:
  pull_request:
    types: [opened, synchronize, reopened, closed]
name: TOC Generator
jobs:
  generateTOC:
    name: TOC Generator
    runs-on: ubuntu-latest
    steps:
      - uses: technote-space/toc-generator@v4

Context variables

namedescription
PR_NUMBERpull_request.number (例:11)
PR_NUMBER_REF#${pull_request.number} (例:#11)
PR_IDpull_request.id (例:21031067)
PR_HEAD_REFpull_request.head.ref (例:change)
PR_BASE_REFpull_request.base.ref (例:main)
PR_MERGE_REFpull_request.base.ref (例:change -> main)
PR_TITLEpull_request.title (例:update the README with new information.)

Payload example

Context PR variables

namedescription
PR_LINKプルリクエストへのリンク
COMMANDS_OUTPUTTOC コマンドの結果
FILES_SUMMARY例:Changed 2 files
FILES変更されたファイル一覧

設定例

例1

ブランチを制限しないでPush時にアクションを実行し直接コミット

on: push
name: TOC Generator
jobs:
  generateTOC:
    name: TOC Generator
    runs-on: ubuntu-latest
    steps:
      - uses: technote-space/toc-generator@v4

例2

release/ から始まるブランチのみを対象にPull Request更新時に実行しPull Requestを作成または更新

on:
  pull_request:
    types: [opened, synchronize, reopened, closed]
name: TOC Generator
jobs:
  generateTOC:
    name: TOC Generator
    runs-on: ubuntu-latest
    steps:
      - uses: technote-space/toc-generator@v4
        with:
          CREATE_PR: true
          TARGET_BRANCH_PREFIX: release/

例3

デフォルトブランチのみを対象にスケジュールでアクションを実行し直接コミット
(他のワークフローの起動のために作成したTokenを使用)

on:
  schedule:
    - cron: "0 23 * * *"
name: TOC Generator
jobs:
  generateTOC:
    name: TOC Generator
    runs-on: ubuntu-latest
    steps:
      - uses: technote-space/toc-generator@v4
        with:
          GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
          CHECK_ONLY_DEFAULT_BRANCH: true

Author

GitHub (Technote)
Blog

4.3.1

1 year ago

4.3.0

1 year ago

4.2.2

2 years ago

4.2.1

2 years ago

4.2.0

2 years ago

4.1.6

2 years ago

4.1.5

2 years ago

4.1.4

3 years ago

4.1.3

3 years ago

4.1.2

3 years ago

4.1.1

3 years ago

4.1.0

3 years ago

4.0.1

3 years ago

4.0.2

3 years ago

4.0.0

3 years ago

3.1.5

3 years ago

3.1.4

3 years ago

3.1.3

3 years ago

3.1.2

3 years ago

3.1.1

3 years ago

3.1.0

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.6.1

4 years ago

2.6.0

4 years ago

2.5.1

4 years ago

2.5.0

4 years ago

2.4.9

4 years ago

2.4.8

4 years ago

2.4.7

4 years ago

2.4.6

4 years ago

2.4.5

4 years ago

2.4.1

4 years ago

2.4.0

4 years ago

2.3.4

4 years ago

2.3.3

4 years ago

2.3.2

4 years ago

2.3.1

4 years ago

2.3.0

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.7

4 years ago

2.1.6

4 years ago

2.1.5

4 years ago

2.1.4

4 years ago

2.1.3

4 years ago