├── .husky
├── .gitignore
├── pre-commit
└── commit-msg
├── src
├── fixtures
│ ├── test.md
│ ├── doctoc
│ │ ├── README.create1.md
│ │ ├── README.create2.md
│ │ ├── README.horizontal.md
│ │ ├── README.toc-me.md
│ │ ├── README.skip.md
│ │ ├── README.params.md
│ │ ├── README.not.update.md
│ │ ├── expected
│ │ │ ├── README.create1.md
│ │ │ ├── README.toc-me.md
│ │ │ ├── README.horizontal1.md
│ │ │ ├── README.update.md
│ │ │ ├── README.params.md
│ │ │ ├── README.horizontal2.md
│ │ │ ├── README.update.wrap.md
│ │ │ ├── README.update.options.md
│ │ │ └── README.create2.md
│ │ └── README.update.md
│ ├── repos.git.blobs.json
│ ├── repos.git.refs.create.json
│ ├── repos.git.refs.update.json
│ ├── repos.git.trees.json
│ ├── repos.git.commits.get.json
│ ├── repos.git.commits.json
│ ├── issues.comment.create.json
│ ├── repos.get.json
│ └── pulls.update.json
├── setup.ts
├── main.ts
├── constant.ts
└── utils
│ ├── transform.ts
│ ├── doctoc.ts
│ ├── misc.ts
│ ├── doctoc.test.ts
│ ├── misc.test.ts
│ └── process.test.ts
├── .github
├── CODEOWNERS
├── FUNDING.yml
├── card-labeler.yml
├── workflow-details.json
├── pr-labeler.yml
├── workflows
│ ├── project-card-moved.yml
│ ├── issue-opened.yml
│ ├── pr-opened.yml
│ ├── toc.yml
│ ├── sync-workflows.yml
│ ├── check-warnings.yml
│ ├── add-release-tag.yml
│ ├── add-test-tag.yml
│ ├── update-dependencies.yml
│ ├── pr-updated.yml
│ └── ci.yml
├── labeler.yml
├── no-response.yml
├── stale.yml
├── pull_request_template.md
├── release-drafter.yml
├── workflow-settings.json
├── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
├── config.yml
├── CONTRIBUTING.md
└── CODE_OF_CONDUCT.md
├── .lintstagedrc
├── .commitlintrc
├── _config.yml
├── .gitignore
├── .releasegarc
├── .editorconfig
├── tsconfig.json
├── vite.config.ts
├── rollup.config.mjs
├── LICENSE
├── .eslintrc
├── package.json
├── action.yml
├── README.zh.md
├── README.ja.md
├── samples
├── README.horizontal.md
└── README.not-folding.md
└── README.md
/.husky/.gitignore:
--------------------------------------------------------------------------------
1 | _
2 |
--------------------------------------------------------------------------------
/src/fixtures/test.md:
--------------------------------------------------------------------------------
1 | test
--------------------------------------------------------------------------------
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | * @technote-space
2 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | custom: https://paypal.me/technote0space
--------------------------------------------------------------------------------
/.lintstagedrc:
--------------------------------------------------------------------------------
1 | {
2 | "*.{js,jsx,ts,tsx}": "yarn lint:fix"
3 | }
--------------------------------------------------------------------------------
/.commitlintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "@commitlint/config-conventional"
4 | ]
5 | }
--------------------------------------------------------------------------------
/.github/card-labeler.yml:
--------------------------------------------------------------------------------
1 | Backlog:
2 | 'In progress':
3 | - 'Status: In Progress'
4 |
--------------------------------------------------------------------------------
/.github/workflow-details.json:
--------------------------------------------------------------------------------
1 | {
2 | "TOC_TARGET_PATHS": "README*.md,samples/*.md"
3 | }
4 |
--------------------------------------------------------------------------------
/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | . "$(dirname "$0")/_/husky.sh"
3 |
4 | yarn lint-staged
5 |
--------------------------------------------------------------------------------
/.husky/commit-msg:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | . "$(dirname "$0")/_/husky.sh"
3 |
4 | yarn commitlint -- --edit $1
5 |
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-architect
2 |
3 | # Google Analytics
4 | google_analytics: UA-78163306-3
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /.idea
2 | /.vscode
3 | /node_modules
4 | /coverage
5 | /lib
6 | /.work
7 | .eslintcache
8 | .env
9 |
--------------------------------------------------------------------------------
/src/setup.ts:
--------------------------------------------------------------------------------
1 | import { setupGlobal } from '@technote-space/github-action-test-helper';
2 |
3 | setupGlobal();
4 |
--------------------------------------------------------------------------------
/src/fixtures/doctoc/README.create1.md:
--------------------------------------------------------------------------------
1 | TEST
2 |
3 |
4 |
5 |
6 | ## Test1
7 | ## Test2
8 |
--------------------------------------------------------------------------------
/.releasegarc:
--------------------------------------------------------------------------------
1 | {
2 | "inputs": {
3 | "OUTPUT_BUILD_INFO_FILENAME": "build.json",
4 | "TEST_TAG_PREFIX": "test/",
5 | "CLEAN_TEST_TAG": "true"
6 | }
7 | }
--------------------------------------------------------------------------------
/src/main.ts:
--------------------------------------------------------------------------------
1 | import { run } from '@technote-space/github-action-pr-helper';
2 | import { getRunnerArguments } from './utils/misc';
3 |
4 | run(getRunnerArguments());
5 |
--------------------------------------------------------------------------------
/src/fixtures/doctoc/README.create2.md:
--------------------------------------------------------------------------------
1 | TEST
2 |
3 | ## <>& #+"'
4 | ## !"#$%&'()0=~|`{+*}<>?-^¥@;:][,./_
5 | ## #abc
6 | ## C
7 | ## C++
8 | ## C#
9 | ## C#
10 | ## C #
11 |
--------------------------------------------------------------------------------
/src/fixtures/repos.git.blobs.json:
--------------------------------------------------------------------------------
1 | {
2 | "url": "https://api.github.com/repos/hello/world/git/blobs/3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15",
3 | "sha": "3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15"
4 | }
--------------------------------------------------------------------------------
/src/fixtures/doctoc/README.horizontal.md:
--------------------------------------------------------------------------------
1 | TEST
2 |
3 |
4 |
5 |
6 | ## Test1
7 | ## Test2
8 | ### Test2-1
9 | ### Test2-2
10 | ### Test2-2-1
11 | ### Test2-2-2
12 | ## Test3
13 |
--------------------------------------------------------------------------------
/src/fixtures/doctoc/README.toc-me.md:
--------------------------------------------------------------------------------
1 | TEST
2 |
3 |
4 | **test title**
5 |
6 | - [Test1](#test1)
7 | - [Test2](#test2)
8 |
9 |
10 |
11 | ## Test1
12 | ## Test3
13 | ``
14 | ``
15 |
--------------------------------------------------------------------------------
/src/fixtures/doctoc/README.skip.md:
--------------------------------------------------------------------------------
1 |
2 | # Hello, world!
3 |
4 | > You can make code blocks with three back ticks:
5 | >
6 | > ```
7 |
8 | # Add this header
9 |
10 |
And also this one
11 |
12 | > ```
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | end_of_line = lf
6 | insert_final_newline = true
7 | trim_trailing_whitespace = true
8 | indent_style = space
9 | indent_size = 2
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
--------------------------------------------------------------------------------
/.github/pr-labeler.yml:
--------------------------------------------------------------------------------
1 | 'Type: Feature': ['feature/*', 'feat/*']
2 | 'Type: Bug': fix/*
3 | 'Type: Maintenance': ['patch/*', 'chore/*']
4 | 'Type: Release': release/*
5 | 'Type: Refactoring': ['refactor/*', 'refactoring/*']
6 | 'Type: Documentation': ['docs/*', 'doc/*']
7 |
--------------------------------------------------------------------------------
/src/fixtures/doctoc/README.params.md:
--------------------------------------------------------------------------------
1 | TEST
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | ## Test1
10 | ## Test3
11 | ### Test3-1
12 | ### Test3-2
13 | #### Test3-2-1
14 | #### Test3-2-2
15 |
--------------------------------------------------------------------------------
/.github/workflows/project-card-moved.yml:
--------------------------------------------------------------------------------
1 | on:
2 | project_card:
3 | types: [created, moved]
4 |
5 | name: Project Card Event
6 |
7 | jobs:
8 | triage:
9 | name: Auto card labeler
10 | runs-on: ubuntu-latest
11 | timeout-minutes: 3
12 | steps:
13 | - uses: technote-space/auto-card-labeler@v1
14 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "@sindresorhus/tsconfig",
3 | "compilerOptions": {
4 | "outDir": "dist",
5 | "target": "ES2021",
6 | "module": "ES2020",
7 | "lib": [
8 | "ES2021"
9 | ],
10 | "moduleResolution": "node",
11 | "noPropertyAccessFromIndexSignature": false,
12 | "noImplicitAny": false
13 | },
14 | "include": [
15 | "src"
16 | ]
17 | }
--------------------------------------------------------------------------------
/src/fixtures/doctoc/README.not.update.md:
--------------------------------------------------------------------------------
1 | TEST
2 |
3 |
4 |
5 | **test title**
6 |
7 | - [Test1](#test1)
8 | - [Test2](#test2)
9 |
10 |
11 |
12 | ## Test1
13 | ## Test2
14 |
--------------------------------------------------------------------------------
/src/fixtures/doctoc/expected/README.create1.md:
--------------------------------------------------------------------------------
1 | TEST
2 |
3 |
4 |
5 | **test title**
6 |
7 | - [Test1](#test1)
8 | - [Test2](#test2)
9 |
10 |
11 |
12 | ## Test1
13 | ## Test2
14 |
--------------------------------------------------------------------------------
/src/fixtures/doctoc/expected/README.toc-me.md:
--------------------------------------------------------------------------------
1 | TEST
2 |
3 |
4 |
5 | **test title**
6 |
7 | - [Test1](#test1)
8 | - [Test3](#test3)
9 |
10 |
11 |
12 | ## Test1
13 | ## Test3
14 | ``
15 | ``
16 |
--------------------------------------------------------------------------------
/src/fixtures/repos.git.refs.create.json:
--------------------------------------------------------------------------------
1 | {
2 | "ref": "refs/heads/featureA",
3 | "node_id": "MDM6UmVmcmVmcy9oZWFkcy9mZWF0dXJlQQ==",
4 | "url": "https://api.github.com/repos/hello/world/git/refs/heads/featureA",
5 | "object": {
6 | "type": "commit",
7 | "sha": "aa218f56b14c9653891f9e74264a383fa43fefbd",
8 | "url": "https://api.github.com/repos/hello/world/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"
9 | }
10 | }
--------------------------------------------------------------------------------
/src/fixtures/repos.git.refs.update.json:
--------------------------------------------------------------------------------
1 | {
2 | "ref": "refs/heads/featureA",
3 | "node_id": "MDM6UmVmcmVmcy9oZWFkcy9mZWF0dXJlQQ==",
4 | "url": "https://api.github.com/repos/hello/world/git/refs/heads/featureA",
5 | "object": {
6 | "type": "commit",
7 | "sha": "aa218f56b14c9653891f9e74264a383fa43fefbd",
8 | "url": "https://api.github.com/repos/hello/world/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"
9 | }
10 | }
--------------------------------------------------------------------------------
/.github/labeler.yml:
--------------------------------------------------------------------------------
1 | javascript:
2 | - '**/*.js'
3 | typescript:
4 | - '**/*.ts'
5 | php:
6 | - '**/*.php'
7 | python:
8 | - '**/*.py'
9 | cpp:
10 | - '**/*.cpp'
11 | - '**/*.cxx'
12 | - '**/*.cc'
13 | - '**/*.cp'
14 |
15 | 'Type: Testing':
16 | - '**/tests/*'
17 | - '**/test/*'
18 | - '**/__tests__/*'
19 |
20 | 'Type: Documentation':
21 | - '**/*.md'
22 |
23 | 'Type: CI/CD':
24 | - '.github/workflows/*.yml'
25 | - '.circleci/*'
26 | - '.travis.yml'
27 |
--------------------------------------------------------------------------------
/src/fixtures/doctoc/README.update.md:
--------------------------------------------------------------------------------
1 | TEST
2 |
3 |
4 |
5 | **test title**
6 |
7 | - [Test1](#test1)
8 | - [Test2](#test2)
9 | - [Test2-1](#test2-1)
10 |
11 |
12 |
13 | ## Test1
14 | ## Test3
15 | ### Test3-1
16 | ### Test3-2
17 | #### Test3-2-1
18 | #### Test3-2-2
19 |
--------------------------------------------------------------------------------
/vite.config.ts:
--------------------------------------------------------------------------------
1 | ///
2 | import { defineConfig } from 'vite';
3 |
4 | // https://vitejs.dev/config/
5 | export default defineConfig({
6 | test: {
7 | setupFiles: './src/setup.ts',
8 | clearMocks: true,
9 | mockReset: true,
10 | restoreMocks: true,
11 | coverage: {
12 | reporter: ['html', 'lcov', 'text'],
13 | },
14 | deps: {
15 | inline: [/github-action-test-helper/, /github-action-helper/, /github-action-pr-helper/]
16 | },
17 | },
18 | });
19 |
--------------------------------------------------------------------------------
/rollup.config.mjs:
--------------------------------------------------------------------------------
1 | import pluginCommonjs from '@rollup/plugin-commonjs';
2 | import pluginJson from '@rollup/plugin-json';
3 | import pluginNodeResolve from '@rollup/plugin-node-resolve';
4 | import pluginTypescript from '@rollup/plugin-typescript';
5 |
6 | export default {
7 | input: 'src/main.ts',
8 | output: {
9 | file: 'lib/main.js',
10 | format: 'cjs',
11 | },
12 | plugins: [
13 | pluginTypescript(),
14 | pluginNodeResolve(),
15 | pluginCommonjs(),
16 | pluginJson(),
17 | ],
18 | };
19 |
--------------------------------------------------------------------------------
/src/fixtures/repos.git.trees.json:
--------------------------------------------------------------------------------
1 | {
2 | "sha": "cd8274d15fa3ae2ab983129fb037999f264ba9a7",
3 | "url": "https://api.github.com/repos/hello/world/trees/cd8274d15fa3ae2ab983129fb037999f264ba9a7",
4 | "tree": [
5 | {
6 | "path": "file.rb",
7 | "mode": "100644",
8 | "type": "blob",
9 | "size": 132,
10 | "sha": "7c258a9869f33c1e1e1f74fbb32f07c86cb5a75b",
11 | "url": "https://api.github.com/repos/hello/world/git/blobs/7c258a9869f33c1e1e1f74fbb32f07c86cb5a75b"
12 | }
13 | ]
14 | }
--------------------------------------------------------------------------------
/src/fixtures/doctoc/expected/README.horizontal1.md:
--------------------------------------------------------------------------------
1 | TEST
2 |
3 |
4 |
5 | **test title**
6 |
7 |
8 | [Test1]
9 | ・
10 | [Test2]
11 | ・
12 | [Test3]
13 |
14 |
15 |
16 |
17 | ## Test1
18 | ## Test2
19 | ### Test2-1
20 | ### Test2-2
21 | ### Test2-2-1
22 | ### Test2-2-2
23 | ## Test3
24 |
--------------------------------------------------------------------------------
/src/fixtures/doctoc/expected/README.update.md:
--------------------------------------------------------------------------------
1 | TEST
2 |
3 |
4 |
5 | **test title**
6 |
7 | - [Test1](#test1)
8 | - [Test3](#test3)
9 | - [Test3-1](#test3-1)
10 | - [Test3-2](#test3-2)
11 | - [Test3-2-1](#test3-2-1)
12 | - [Test3-2-2](#test3-2-2)
13 |
14 |
15 |
16 | ## Test1
17 | ## Test3
18 | ### Test3-1
19 | ### Test3-2
20 | #### Test3-2-1
21 | #### Test3-2-2
22 |
--------------------------------------------------------------------------------
/src/fixtures/doctoc/expected/README.params.md:
--------------------------------------------------------------------------------
1 | TEST
2 |
3 |
4 |
5 |
6 |
7 | **test title**
8 |
9 | - [Test1](#test1)
10 | - [Test3](#test3)
11 | - [Test3-1](#test3-1)
12 | - [Test3-2](#test3-2)
13 |
14 |
15 |
16 | ## Test1
17 | ## Test3
18 | ### Test3-1
19 | ### Test3-2
20 | #### Test3-2-1
21 | #### Test3-2-2
22 |
--------------------------------------------------------------------------------
/src/fixtures/doctoc/expected/README.horizontal2.md:
--------------------------------------------------------------------------------
1 | TEST
2 |
3 |
4 |
5 | **test title**
6 |
7 |
8 | Test1
9 | |
10 | Test2
11 | |
12 | Test3
13 |
14 |
15 |
16 |
17 | ## Test1
18 | ## Test2
19 | ### Test2-1
20 | ### Test2-2
21 | ### Test2-2-1
22 | ### Test2-2-2
23 | ## Test3
24 |
--------------------------------------------------------------------------------
/src/constant.ts:
--------------------------------------------------------------------------------
1 | import type { Context } from '@actions/github/lib/context';
2 |
3 | export const ACTION_NAME = 'TOC Generator';
4 | export const ACTION_OWNER = 'technote-space';
5 | export const ACTION_REPO = 'toc-generator';
6 | export const TARGET_EVENTS = {
7 | 'push': [
8 | (context: Context): boolean => /^refs\/heads\//.test(context.ref),
9 | ],
10 | 'pull_request': [
11 | 'opened',
12 | 'reopened',
13 | 'synchronize',
14 | 'labeled',
15 | 'unlabeled',
16 | 'closed',
17 | ],
18 | 'schedule': '*',
19 | 'repository_dispatch': '*',
20 | 'workflow_dispatch': '*',
21 | 'workflow_run': '*',
22 | };
23 |
--------------------------------------------------------------------------------
/src/fixtures/doctoc/expected/README.update.wrap.md:
--------------------------------------------------------------------------------
1 | TEST
2 |
3 |
4 |
5 |
6 | test title
7 |
8 | - [Test1](#test1)
9 | - [Test3](#test3)
10 | - [Test3-1](#test3-1)
11 | - [Test3-2](#test3-2)
12 | - [Test3-2-1](#test3-2-1)
13 | - [Test3-2-2](#test3-2-2)
14 |
15 |
16 |
17 |
18 | ## Test1
19 | ## Test3
20 | ### Test3-1
21 | ### Test3-2
22 | #### Test3-2-1
23 | #### Test3-2-2
24 |
--------------------------------------------------------------------------------
/src/fixtures/doctoc/expected/README.update.options.md:
--------------------------------------------------------------------------------
1 | TEST
2 |
3 |
4 |
5 |
6 | test title
7 |
8 | ☆ [Test1](#test1)
9 | ☆ [Test3](#test3)
10 | ☆ [Test3-1](#test3-1)
11 | ☆ [Test3-2](#test3-2)
12 |
13 | *generated with [TOC Generator](https://github.com/technote-space/toc-generator)*
14 |
15 |
16 |
17 |
18 | ## Test1
19 | ## Test3
20 | ### Test3-1
21 | ### Test3-2
22 | #### Test3-2-1
23 | #### Test3-2-2
24 |
--------------------------------------------------------------------------------
/src/fixtures/doctoc/expected/README.create2.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | **test title**
4 |
5 | - [<>& #+"'](#-)
6 | - [!"#$%&'()0=~|`{+*}<>?-^¥@;:][,./_](#0-_)
7 | - [#abc](#abc)
8 | - [C](#c)
9 | - [C++](#c-1)
10 | - [C#](#c-2)
11 | - [C#](#c-3)
12 | - [C](#c-4)
13 |
14 |
15 |
16 | TEST
17 |
18 | ## <>& #+"'
19 | ## !"#$%&'()0=~|`{+*}<>?-^¥@;:][,./_
20 | ## #abc
21 | ## C
22 | ## C++
23 | ## C#
24 | ## C#
25 | ## C #
26 |
--------------------------------------------------------------------------------
/.github/no-response.yml:
--------------------------------------------------------------------------------
1 | # Configuration for probot-no-response - https://github.com/probot/no-response
2 |
3 | # Number of days of inactivity before an Issue is closed for lack of response
4 | daysUntilClose: 14
5 | # Label requiring a response
6 | responseRequiredLabel: "Status: More Information Needed"
7 | # Comment to post when closing an Issue for lack of response. Set to `false` to disable
8 | closeComment: >
9 | This issue has been automatically closed because there has been no response
10 | to our request for more information from the original author. With only the
11 | information that is currently in the issue, we don't have enough information
12 | to take action. Please reach out if you have or find the answers we need so
13 | that we can investigate further.
14 |
--------------------------------------------------------------------------------
/.github/stale.yml:
--------------------------------------------------------------------------------
1 | # Number of days of inactivity before an issue becomes stale
2 | daysUntilStale: 180
3 | # Number of days of inactivity before a stale issue is closed
4 | daysUntilClose: 30
5 | # Issues with these labels will never be considered stale
6 | exemptLabels:
7 | - "Priority: Critical"
8 | - "Type: Security"
9 | # Label to use when marking an issue as stale
10 | staleLabel: "Status: Abandoned"
11 | # Comment to post when marking an issue as stale. Set to `false` to disable
12 | markComment: >
13 | This issue has been automatically marked as stale because it has not had
14 | recent activity. It will be closed if no further activity occurs. Thank you
15 | for your contributions.
16 | # Comment to post when closing a stale issue. Set to `false` to disable
17 | closeComment: false
--------------------------------------------------------------------------------
/.github/workflows/issue-opened.yml:
--------------------------------------------------------------------------------
1 | on:
2 | issues:
3 | types: [opened]
4 |
5 | name: Issue opened
6 |
7 | jobs:
8 | assign:
9 | name: Assign issues to project
10 | runs-on: ubuntu-latest
11 | timeout-minutes: 3
12 | steps:
13 | - uses: technote-space/load-config-action@v1
14 | with:
15 | CONFIG_FILENAME: workflow-settings.json, workflow-details.json
16 | IGNORE_WARNING: 'true'
17 | - uses: technote-space/create-project-card-action@v1
18 | with:
19 | PROJECT: ${{ env.PROJECT }}
20 | COLUMN: ${{ env.ISSUE_COLUMN }}
21 |
22 | assignAuthor:
23 | name: Assign author to issue
24 | runs-on: ubuntu-latest
25 | timeout-minutes: 3
26 | steps:
27 | - uses: technote-space/assign-author@v1
28 |
--------------------------------------------------------------------------------
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | ## Description: 概要
2 |
3 |
4 |
5 | ## Changes: 変更内容
6 |
7 |
8 |
9 |
10 |
11 |
12 | ## Expected Impact: 影響範囲
13 |
14 |
15 |
16 | ## Operating Requirements: 動作要件
17 |
18 |
19 |
20 | ## Additional context: 補足
21 |
22 |
23 |
--------------------------------------------------------------------------------
/.github/release-drafter.yml:
--------------------------------------------------------------------------------
1 | # Config for https://github.com/apps/release-drafter
2 | name-template: 'v$NEXT_PATCH_VERSION'
3 | tag-template: 'v$NEXT_PATCH_VERSION'
4 | categories:
5 | - title: ':rocket: Features'
6 | labels:
7 | - 'Type: Feature'
8 | - 'Type: Refactoring'
9 | - title: ':bug: Bug Fixes'
10 | labels:
11 | - 'Type: Bug'
12 | - 'Type: Security'
13 | - title: ':wrench: Maintenance'
14 | labels:
15 | - 'Type: Maintenance'
16 | - 'Type: CI/CD'
17 | - title: ':green_book: Docs'
18 | labels:
19 | - 'Type: Documentation'
20 | - title: ':white_check_mark: Tested'
21 | labels:
22 | - 'Type: Testing'
23 | - title: ':sparkles: All Changes'
24 | labels:
25 | - 'Type: Release'
26 | exclude-labels:
27 | - 'dependencies'
28 | template: |
29 | ## What’s Changed
30 |
31 | $CHANGES
32 |
--------------------------------------------------------------------------------
/.github/workflow-settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "EXCLUDE_MESSAGES": [
3 | "update package version",
4 | "update packages",
5 | "update wp version",
6 | "trigger workflow",
7 | "update TOC"
8 | ],
9 | "PROJECT": "Backlog",
10 | "ISSUE_COLUMN": "To do",
11 | "PR_COLUMN": "In progress",
12 | "PR_BODY_TITLE": "## Changes",
13 | "TOC_FOLDING": "1",
14 | "TOC_MAX_HEADER_LEVEL": "3",
15 | "TOC_TITLE": "Details",
16 | "TOC_CREATE_PR": "true",
17 | "TOC_TARGET_PATHS": "README*.md",
18 | "BRANCH_PREFIX": "release/",
19 | "ANNOTATION_EXCLUDE_PATTERNS": [
20 | ">> warning ",
21 | ">> hint: ",
22 | "Cloning into",
23 | "has unmet peer dependency",
24 | "has incorrect peer dependency",
25 | "Using version",
26 | "ci-helper",
27 | "tests/bootstrap.php"
28 | ],
29 | "CHANGE_TEMPLATE": "- [ ] ${TITLE} (#${NUMBER}) @${AUTHOR}"
30 | }
31 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: 'technote-space'
7 |
8 | ---
9 |
10 | ## Please describe your suggestion: 提案の概要
11 |
12 |
13 |
14 | ## Describe the solution you'd like: 考えうる解決方法
15 |
16 |
17 |
18 | ## Describe alternatives you've considered: 考えうる代替案
19 |
20 |
21 |
22 | ## Additional context: 補足
23 |
24 |
25 |
--------------------------------------------------------------------------------
/.github/workflows/pr-opened.yml:
--------------------------------------------------------------------------------
1 | on:
2 | pull_request_target:
3 | types: [opened]
4 |
5 | name: Pull Request opened
6 |
7 | jobs:
8 | assignToProject:
9 | name: Assign PullRequest to Project
10 | runs-on: ubuntu-latest
11 | timeout-minutes: 3
12 | steps:
13 | - uses: technote-space/load-config-action@v1
14 | with:
15 | CONFIG_FILENAME: workflow-settings.json, workflow-details.json
16 | IGNORE_WARNING: 'true'
17 | - uses: technote-space/create-project-card-action@v1
18 | with:
19 | PROJECT: ${{ env.PROJECT }}
20 | COLUMN: ${{ env.PR_COLUMN }}
21 | GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
22 |
23 | assignAuthor:
24 | name: Assign author to PR
25 | runs-on: ubuntu-latest
26 | timeout-minutes: 3
27 | steps:
28 | - uses: technote-space/assign-author@v1
29 |
30 | addLabelsByBranch:
31 | name: PR Labeler
32 | runs-on: ubuntu-latest
33 | timeout-minutes: 3
34 | steps:
35 | - uses: technote-space/pr-labeler-action@v4
36 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: 'technote-space'
7 |
8 | ---
9 |
10 | ## Describe the bug: バグの概要
11 |
12 |
13 |
14 | ## To Reproduce: 再現手順
15 | Steps to reproduce the behavior:
16 | 1. Go to '...'
17 | 2. Click on '....'
18 | 3. Scroll down to '....'
19 | 4. See error
20 |
21 | ## Expected behavior: 期待する動作
22 |
23 |
24 |
25 | ## Screenshots: スクリーンショット
26 |
27 |
28 |
29 | ## Operating environment: バグが発生した環境
30 | - Version of software
31 | - OS: [e.g. Windows10]
32 | - Browser: [e.g. Chrome, Safari]
33 | - etc.
34 |
35 | ## Additional context: 補足
36 |
37 |
38 |
--------------------------------------------------------------------------------
/.github/workflows/toc.yml:
--------------------------------------------------------------------------------
1 | on:
2 | pull_request:
3 | types: [opened, synchronize, reopened, closed]
4 |
5 | concurrency:
6 | group: ${{ github.workflow }}-${{ github.ref }}
7 |
8 | name: TOC Generator
9 |
10 | jobs:
11 | toc:
12 | if: github.event.pull_request.head.user.id == github.event.pull_request.base.user.id
13 | name: TOC Generator
14 | runs-on: ubuntu-latest
15 | timeout-minutes: 3
16 | steps:
17 | - uses: technote-space/load-config-action@v1
18 | with:
19 | CONFIG_FILENAME: workflow-settings.json, workflow-details.json
20 | IGNORE_WARNING: 'true'
21 | - uses: technote-space/toc-generator@gh-actions
22 | with:
23 | GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
24 | TARGET_BRANCH_PREFIX: ${{ env.BRANCH_PREFIX }}
25 | FOLDING: ${{ env.TOC_FOLDING }}
26 | MAX_HEADER_LEVEL: ${{ env.TOC_MAX_HEADER_LEVEL }}
27 | TOC_TITLE: ${{ env.TOC_TITLE }}
28 | CREATE_PR: ${{ env.TOC_CREATE_PR }}
29 | TARGET_PATHS: ${{ env.TOC_TARGET_PATHS }}
30 | FOOTER: ${{ env.TOC_FOOTER }}
31 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2019 Technote
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/src/fixtures/repos.git.commits.get.json:
--------------------------------------------------------------------------------
1 | {
2 | "sha": "7638417db6d59f3c431d3e1f261cc637155684cd",
3 | "url": "https://api.github.com/repos/hello/world/git/commits/7638417db6d59f3c431d3e1f261cc637155684cd",
4 | "author": {
5 | "date": "2014-11-07T22:01:45Z",
6 | "name": "Monalisa Octocat",
7 | "email": "octocat@github.com"
8 | },
9 | "committer": {
10 | "date": "2014-11-07T22:01:45Z",
11 | "name": "Monalisa Octocat",
12 | "email": "octocat@github.com"
13 | },
14 | "message": "added readme, because im a good github citizen",
15 | "tree": {
16 | "url": "https://api.github.com/repos/hello/world/git/trees/691272480426f78a0138979dd3ce63b77f706feb",
17 | "sha": "691272480426f78a0138979dd3ce63b77f706feb"
18 | },
19 | "parents": [
20 | {
21 | "url": "https://api.github.com/repos/hello/world/git/commits/1acc419d4d6a9ce985db7be48c6349a0475975b5",
22 | "sha": "1acc419d4d6a9ce985db7be48c6349a0475975b5"
23 | }
24 | ],
25 | "verification": {
26 | "verified": false,
27 | "reason": "unsigned",
28 | "signature": null,
29 | "payload": null
30 | }
31 | }
--------------------------------------------------------------------------------
/src/fixtures/repos.git.commits.json:
--------------------------------------------------------------------------------
1 | {
2 | "sha": "7638417db6d59f3c431d3e1f261cc637155684cd",
3 | "node_id": "MDY6Q29tbWl0NzYzODQxN2RiNmQ1OWYzYzQzMWQzZTFmMjYxY2M2MzcxNTU2ODRjZA==",
4 | "url": "https://api.github.com/repos/hello/world/git/commits/7638417db6d59f3c431d3e1f261cc637155684cd",
5 | "author": {
6 | "date": "2014-11-07T22:01:45Z",
7 | "name": "Monalisa Octocat",
8 | "email": "octocat@github.com"
9 | },
10 | "committer": {
11 | "date": "2014-11-07T22:01:45Z",
12 | "name": "Monalisa Octocat",
13 | "email": "octocat@github.com"
14 | },
15 | "message": "my commit message",
16 | "tree": {
17 | "url": "https://api.github.com/repos/hello/world/git/trees/827efc6d56897b048c772eb4087f854f46256132",
18 | "sha": "827efc6d56897b048c772eb4087f854f46256132"
19 | },
20 | "parents": [
21 | {
22 | "url": "https://api.github.com/repos/hello/world/git/commits/7d1b31e74ee336d15cbd21741bc88a537ed063a0",
23 | "sha": "7d1b31e74ee336d15cbd21741bc88a537ed063a0"
24 | }
25 | ],
26 | "verification": {
27 | "verified": false,
28 | "reason": "unsigned",
29 | "signature": null,
30 | "payload": null
31 | }
32 | }
--------------------------------------------------------------------------------
/src/utils/transform.ts:
--------------------------------------------------------------------------------
1 | import fs from 'fs';
2 | import { getInput } from '@actions/core' ;
3 | import { transform, CHECK_OPENING_COMMENT, CHECK_CLOSING_COMMENT, CHECK_SKIP_COMMENT } from '@technote-space/doctoc';
4 | import { Utils } from '@technote-space/github-action-helper';
5 | import {
6 | isNoTitle,
7 | getEntryPrefix,
8 | getMaxHeaderLevel,
9 | getArrayInput,
10 | isFolding,
11 | } from './misc';
12 |
13 | export const transformWithWrap = (path: string, title: string): { transformed: boolean; path: string; data: string } => {
14 | const { transformed, data } = transform(fs.readFileSync(path, 'utf8'), {
15 | maxHeaderLevel: getMaxHeaderLevel(),
16 | title,
17 | isNotitle: isNoTitle(title),
18 | isFolding: isFolding(),
19 | entryPrefix: getEntryPrefix(),
20 | checkOpeningComments: Utils.uniqueArray(getArrayInput('OPENING_COMMENT').concat(CHECK_OPENING_COMMENT)),
21 | checkClosingComments: Utils.uniqueArray(getArrayInput('CLOSING_COMMENT').concat(CHECK_CLOSING_COMMENT)),
22 | checkSkipComments: Utils.uniqueArray(getArrayInput('SKIP_COMMENT').concat(CHECK_SKIP_COMMENT)),
23 | isCustomMode: Utils.getBoolValue(getInput('CUSTOM_MODE') || getInput('HTML_MODE')),
24 | customTemplate: getInput('CUSTOM_TEMPLATE') || getInput('HTML_TEMPLATE'),
25 | itemTemplate: getInput('ITEM_TEMPLATE'),
26 | separator: getInput('SEPARATOR'),
27 | footer: getInput('FOOTER'),
28 | });
29 | return { path, transformed, data };
30 | };
31 |
--------------------------------------------------------------------------------
/src/fixtures/issues.comment.create.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": 1,
3 | "node_id": "MDEyOklzc3VlQ29tbWVudDE=",
4 | "url": "https://api.github.com/repos/octocat/Hello-World/issues/comments/1",
5 | "html_url": "https://github.com/octocat/Hello-World/issues/1347#issuecomment-1",
6 | "body": "Me too",
7 | "user": {
8 | "login": "octocat",
9 | "id": 1,
10 | "node_id": "MDQ6VXNlcjE=",
11 | "avatar_url": "https://github.com/images/error/octocat_happy.gif",
12 | "gravatar_id": "",
13 | "url": "https://api.github.com/users/octocat",
14 | "html_url": "https://github.com/octocat",
15 | "followers_url": "https://api.github.com/users/octocat/followers",
16 | "following_url": "https://api.github.com/users/octocat/following{/other_user}",
17 | "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
18 | "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
19 | "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
20 | "organizations_url": "https://api.github.com/users/octocat/orgs",
21 | "repos_url": "https://api.github.com/users/octocat/repos",
22 | "events_url": "https://api.github.com/users/octocat/events{/privacy}",
23 | "received_events_url": "https://api.github.com/users/octocat/received_events",
24 | "type": "User",
25 | "site_admin": false
26 | },
27 | "created_at": "2011-04-14T16:00:49Z",
28 | "updated_at": "2011-04-14T16:00:49Z"
29 | }
--------------------------------------------------------------------------------
/.github/config.yml:
--------------------------------------------------------------------------------
1 | # Configuration for request-info - https://github.com/behaviorbot/request-info
2 |
3 | # *Required* Comment to reply with
4 | requestInfoReplyComment: >
5 | :clap: We would appreciate it if you could provide us with more info about this issue/pr!
6 |
7 | # *OPTIONAL* default titles to check against for lack of descriptiveness
8 | # MUST BE ALL LOWERCASE
9 | requestInfoDefaultTitles:
10 | - update readme.md
11 | - updates
12 | - update
13 |
14 | # *OPTIONAL* Label to be added to Issues and Pull Requests with insufficient information given
15 | requestInfoLabelToAdd: "Status: More Information Needed"
16 |
17 |
18 |
19 |
20 | # Configuration for welcome - https://github.com/behaviorbot/welcome
21 |
22 | # Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome
23 |
24 | # Comment to be posted to on first time issues
25 | newIssueWelcomeComment: >
26 | :raised_hands: Thanks for opening your first issue here! Be sure to follow the issue template!
27 |
28 | # Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome
29 |
30 | # Comment to be posted to on PRs from first time contributors in your repository
31 | newPRWelcomeComment: >
32 | :raised_hands: Thanks for opening this pull request! Please check out our contributing guidelines.
33 |
34 | # Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge
35 |
36 | # Comment to be posted to on pull requests merged by a first time user
37 | firstPRMergeComment: >
38 | :tada: Congrats on merging your first pull request! We here at behaviorbot are proud of you!
39 |
40 |
41 |
42 | # Configuration for todo - https://github.com/jasonetco/todo
43 | todo:
44 | - label: "Type: Todo"
--------------------------------------------------------------------------------
/.github/workflows/sync-workflows.yml:
--------------------------------------------------------------------------------
1 | on:
2 | schedule:
3 | - cron: 0 14 * * 4
4 | repository_dispatch:
5 | types: [sync-workflows]
6 | workflow_dispatch:
7 |
8 | name: Sync workflows
9 | jobs:
10 | release:
11 | name: Sync workflows
12 | runs-on: ubuntu-latest
13 | timeout-minutes: 5
14 | steps:
15 | - name: Set variables
16 | run: |
17 | echo "MINUTE=$(echo "${GITHUB_REPOSITORY}" | md5sum | tr -d -c 0-9 | xargs -I{} echo {}123456789 | cut -c 2-9 | xargs -I{} bash -c 'echo $((1{} % 60))')" >> $GITHUB_ENV
18 | echo "HOUR=$(echo "${GITHUB_REPOSITORY}" | md5sum | tr -d -c 0-9 | xargs -I{} echo {}123456789 | cut -c 2-9 | xargs -I{} bash -c 'echo $((1{} % 24))')" >> $GITHUB_ENV
19 | echo "DAY=$(echo "${GITHUB_REPOSITORY}" | md5sum | tr -d -c 0-9 | xargs -I{} echo {}123456789 | cut -c 2-9 | xargs -I{} bash -c 'echo $((1{} % 7))')" >> $GITHUB_ENV
20 |
21 | - name: Sync workflows
22 | uses: technote-space/create-pr-action@v2
23 | with:
24 | GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
25 | EXECUTE_COMMANDS: |
26 | rm -rdf .github/workflows/.tmp
27 | mkdir -p .github/workflows/.tmp
28 | git clone --depth=1 https://github.com/technote-space/github-actions-workflows.git .github/workflows/.tmp/workflows
29 |
30 | bash .github/workflows/.tmp/workflows/gh-actions/copy.sh
31 | sed -i "s/cron:.\+$/cron: ${MINUTE} ${HOUR} * * ${DAY}/" .github/workflows/update-dependencies.yml
32 |
33 | rm -rdf .github/workflows/.tmp
34 | COMMIT_MESSAGE: 'chore: sync workflows'
35 | PR_BRANCH_PREFIX: chore/
36 | PR_BRANCH_NAME: 'chore-sync-workflows'
37 | PR_TITLE: 'chore: sync workflows'
38 | ONLY_DEFAULT_BRANCH: true
39 |
--------------------------------------------------------------------------------
/.github/workflows/check-warnings.yml:
--------------------------------------------------------------------------------
1 | on:
2 | workflow_run:
3 | workflows:
4 | - CI
5 | - Sync workflows
6 | - Update dependencies
7 | - Broken Link Check
8 | types:
9 | - completed
10 |
11 | name: Check Warnings
12 |
13 | jobs:
14 | annotations:
15 | name: Annotations
16 | runs-on: ubuntu-latest
17 | timeout-minutes: 3
18 | steps:
19 | - uses: technote-space/load-config-action@v1
20 | with:
21 | CONFIG_FILENAME: workflow-settings.json, workflow-details.json
22 | IGNORE_WARNING: 'true'
23 | - uses: technote-space/download-annotations-action@v2
24 | id: annotations
25 | with:
26 | TARGET_RUN_ID: ${{ github.event.workflow_run.id }}
27 | INCLUDE_LEVELS: warning
28 | EXCLUDE_MESSAGE_PATTERNS: ${{ env.ANNOTATION_EXCLUDE_PATTERNS }}
29 | - name: Build attachments
30 | run: |
31 | arr1='[{"fields":[{"title":"repo","value":"","short":true},{"title":"action","value":"<${{ github.event.workflow_run.html_url }}|summary>","short":true}]}]'
32 | arr2=$(echo '${{ steps.annotations.outputs.messages }}' | jq -c 'map({"color":"warning","text":"```\(.)```"})')
33 | echo "SLACK_ATTACHMENTS=$(jq --argjson arr1 "$arr1" --argjson arr2 "$arr2" -nc '$arr1 + $arr2')" >> $GITHUB_ENV
34 | if: steps.annotations.outputs.number > 0
35 | - uses: 8398a7/action-slack@v3
36 | with:
37 | status: custom
38 | fields: repo
39 | custom_payload: |
40 | {
41 | text: "Warning annotations",
42 | attachments: ${{ env.SLACK_ATTACHMENTS }}
43 | }
44 | env:
45 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
46 | if: steps.annotations.outputs.number > 0 && env.SLACK_WEBHOOK_URL
47 |
--------------------------------------------------------------------------------
/.github/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 | [issues]: https://github.com/technote-space/toc-generator/issues
3 | [fork]: https://github.com/technote-space/toc-generator/fork
4 | [pr]: https://github.com/technote-space/toc-generator/compare
5 | [eslint]: https://eslint.org/
6 | [jest]: https://jestjs.io/
7 | [code-of-conduct]: CODE_OF_CONDUCT.md
8 |
9 | When contributing to this repository, please first discuss the change you wish to make via [issue][issues] with the owners of this repository before making a change.
10 |
11 | Please note we have a [Contributor Code of Conduct][code-of-conduct], please follow it in all your interactions with the project.
12 |
13 | ## Submitting a pull request
14 |
15 | 1. [Fork][fork] and clone the repository
16 | 1. Make sure the tests pass on your machine: `yarn test`, which contains
17 | - [`ESLint`][eslint]
18 | - [`Jest`][jest]
19 | 1. Create a new branch: `git checkout -b my-branch-name`
20 | 1. Make your change, add tests, and make sure the tests still pass.
21 | 1. Push to your fork and [submit a pull request][pr].
22 | 1. Pat your self on the back and wait for your pull request to be reviewed and merged.
23 |
24 | Here are a few things you can do that will increase the likelihood of your pull request being accepted:
25 | - Write and update tests.
26 | - Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
27 | - Write a [good commit message](https://github.com/erlang/otp/wiki/writing-good-commit-messages).
28 |
29 | Work in Progress pull request are also welcome to get feedback early on, or if there is something blocked you.
30 |
31 | ## Resources
32 |
33 | - [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
34 | - [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
35 | - [GitHub Help](https://help.github.com)
36 |
--------------------------------------------------------------------------------
/.github/workflows/add-release-tag.yml:
--------------------------------------------------------------------------------
1 | on:
2 | pull_request:
3 | branches:
4 | - master
5 | - main
6 | - develop/v*
7 | types: [closed]
8 |
9 | concurrency:
10 | group: ${{ github.workflow }}-${{ github.ref }}
11 |
12 | name: Add release tag
13 |
14 | jobs:
15 | tag:
16 | name: Add release tag
17 | runs-on: ubuntu-latest
18 | timeout-minutes: 3
19 | if: github.event.pull_request.merged == true && github.event.pull_request.head.user.id == github.event.pull_request.base.user.id && startsWith(github.head_ref, 'release/')
20 | steps:
21 | - uses: technote-space/load-config-action@v1
22 | with:
23 | CONFIG_FILENAME: workflow-settings.json, workflow-details.json
24 | IGNORE_WARNING: 'true'
25 | - name: Get version
26 | uses: technote-space/get-next-version-action@v1
27 | with:
28 | EXCLUDE_MESSAGES: ${{ env.EXCLUDE_MESSAGES }}
29 | if: "! startsWith(github.head_ref, 'release/v')"
30 | - name: Get version
31 | run: echo "NEXT_VERSION=${HEAD_REF#release/}" >> $GITHUB_ENV
32 | env:
33 | HEAD_REF: ${{ github.head_ref }}
34 | if: startsWith(github.head_ref, 'release/v')
35 | - uses: actions/github-script@v3
36 | with:
37 | github-token: ${{ secrets.ACCESS_TOKEN }}
38 | script: |
39 | github.git.createRef({
40 | owner: context.repo.owner,
41 | repo: context.repo.repo,
42 | ref: `refs/tags/${process.env.NEXT_VERSION}`,
43 | sha: context.sha
44 | })
45 | if: env.NEXT_VERSION
46 | - uses: actions/github-script@v3
47 | with:
48 | github-token: ${{ secrets.ACCESS_TOKEN }}
49 | script: |
50 | github.git.createRef({
51 | owner: context.repo.owner,
52 | repo: context.repo.repo,
53 | ref: `refs/heads/release/next-${process.env.NEXT_VERSION}`,
54 | sha: context.sha
55 | })
56 | if: env.NEXT_VERSION
57 |
--------------------------------------------------------------------------------
/.github/workflows/add-test-tag.yml:
--------------------------------------------------------------------------------
1 | on:
2 | pull_request:
3 | types: [synchronize]
4 |
5 | concurrency:
6 | group: ${{ github.workflow }}-${{ github.ref }}
7 |
8 | name: Add test tag
9 |
10 | jobs:
11 | tag:
12 | name: Add test tag
13 | runs-on: ubuntu-latest
14 | timeout-minutes: 3
15 | if: github.event.pull_request.head.user.id == github.event.pull_request.base.user.id && startsWith(github.head_ref, 'release/')
16 | steps:
17 | - uses: technote-space/load-config-action@v1
18 | with:
19 | CONFIG_FILENAME: workflow-settings.json, workflow-details.json
20 | IGNORE_WARNING: 'true'
21 | - uses: actions/checkout@v3
22 | - uses: technote-space/get-git-comment-action@v1
23 | - name: Get version
24 | uses: technote-space/get-next-version-action@v1
25 | with:
26 | EXCLUDE_MESSAGES: ${{ env.EXCLUDE_MESSAGES }}
27 | if: "! startsWith(github.head_ref, 'release/v') && (contains(env.COMMIT_MESSAGE, 'chore: update dependencies') || contains(env.COMMIT_MESSAGE, 'chore: update npm dependencies'))"
28 | - name: Get version
29 | run: echo "NEXT_VERSION=${HEAD_REF#release/}" >> $GITHUB_ENV
30 | env:
31 | HEAD_REF: ${{ github.head_ref }}
32 | if: "startsWith(github.head_ref, 'release/v') && (contains(env.COMMIT_MESSAGE, 'chore: update dependencies') || contains(env.COMMIT_MESSAGE, 'chore: update npm dependencies'))"
33 | - name: Get tag name
34 | run: echo "TAG_NAME=${NEXT_VERSION}.${RUN_ID}" >> $GITHUB_ENV
35 | env:
36 | HEAD_REF: ${{ github.head_ref }}
37 | RUN_ID: ${{ github.run_id }}
38 | if: env.NEXT_VERSION
39 | - uses: actions/github-script@v3
40 | with:
41 | github-token: ${{ secrets.ACCESS_TOKEN }}
42 | script: |
43 | github.git.createRef({
44 | owner: context.repo.owner,
45 | repo: context.repo.repo,
46 | ref: `refs/tags/test/${process.env.TAG_NAME}`,
47 | sha: context.payload.pull_request.head.sha
48 | })
49 | if: env.TAG_NAME
50 |
--------------------------------------------------------------------------------
/src/utils/doctoc.ts:
--------------------------------------------------------------------------------
1 | import type { Logger } from '@technote-space/github-action-log-helper';
2 | import type { CommandOutput, ExecuteTask } from '@technote-space/github-action-pr-helper/dist/types';
3 | import fs from 'fs';
4 | import { findMarkdownFiles } from '@technote-space/doctoc';
5 | import { Utils } from '@technote-space/github-action-helper';
6 | import { sync } from 'fast-glob';
7 | import { cleanPath } from './misc';
8 | import { transformWithWrap } from './transform';
9 |
10 | export const transformAndSave = (files: Array<{ path: string }>, title: string): { changed: Array<{ path: string }>; unchanged: Array<{ path: string }> } => {
11 | const transformed = files.map(file => transformWithWrap(file.path, title));
12 | const changed = transformed.filter(item => item.transformed);
13 | const unchanged = transformed.filter(item => !item.transformed);
14 |
15 | changed.forEach(item => {
16 | fs.writeFileSync(item.path, item.data, 'utf8');
17 | });
18 |
19 | return { changed, unchanged };
20 | };
21 |
22 | const parsePaths = (paths: Array): Array => sync(paths.map(path => cleanPath(path)), {
23 | onlyFiles: false,
24 | caseSensitiveMatch: false,
25 | cwd: Utils.getWorkspace(),
26 | });
27 |
28 | export const executeDoctoc = (paths: Array, title: string, logger: Logger): { changed: Array; unchanged: Array } => parsePaths(paths).map(path => {
29 | const stat = fs.statSync(path);
30 | if (stat.isDirectory()) {
31 | logger.displayCommand('DocToccing "%s" and its sub directories.', path);
32 | return transformAndSave(findMarkdownFiles(path), title);
33 | }
34 |
35 | logger.displayCommand('DocToccing single file "%s".', path);
36 | return transformAndSave([{ path }], title);
37 | }).reduce((acc, value) => ({
38 | changed: acc.changed.concat(value.changed.map(item => item.path)),
39 | unchanged: acc.unchanged.concat(value.unchanged.map(item => item.path)),
40 | }), {
41 | changed: [] as Array,
42 | unchanged: [] as Array,
43 | });
44 |
45 | export const doctoc = (paths: Array, title: string, logger: Logger): ExecuteTask => {
46 | return async(): Promise => {
47 | // process.cwd is not available in Worker threads.
48 | const cwd = process.cwd;
49 | process.cwd = (): string => Utils.getWorkspace();
50 | const results = executeDoctoc(paths, title, logger);
51 | process.cwd = cwd;
52 | return {
53 | command: 'Run doctoc',
54 | stdout: [
55 | 'changed:',
56 | ...results.changed.map(item => ` - ${item}`),
57 | 'unchanged:',
58 | ...results.unchanged.map(item => ` - ${item}`),
59 | ],
60 | stderr: [],
61 | };
62 | };
63 | };
64 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "eslint:recommended",
4 | "plugin:@typescript-eslint/recommended",
5 | "plugin:@typescript-eslint/eslint-recommended"
6 | ],
7 | "plugins": [
8 | "@typescript-eslint",
9 | "import"
10 | ],
11 | "parser": "@typescript-eslint/parser",
12 | "parserOptions": {
13 | "sourceType": "module",
14 | "ecmaVersion": 2018
15 | },
16 | "env": {
17 | "node": true,
18 | "jest": true,
19 | "es6": true,
20 | "browser": true
21 | },
22 | "settings": {
23 | "react": {
24 | "version": "latest"
25 | }
26 | },
27 | "rules": {
28 | "camelcase": [
29 | "error",
30 | {
31 | "properties": "always"
32 | }
33 | ],
34 | "quotes": [
35 | "error",
36 | "single",
37 | "avoid-escape"
38 | ],
39 | "key-spacing": [
40 | "error",
41 | {
42 | "singleLine": {
43 | "beforeColon": false,
44 | "afterColon": true
45 | },
46 | "multiLine": {
47 | "beforeColon": false,
48 | "afterColon": true
49 | }
50 | }
51 | ],
52 | "eqeqeq": "error",
53 | "block-scoped-var": "error",
54 | "complexity": [
55 | "error",
56 | {
57 | "maximum": 20
58 | }
59 | ],
60 | "default-case": "error",
61 | "dot-location": [
62 | "error",
63 | "property"
64 | ],
65 | "guard-for-in": "error",
66 | "no-eval": "error",
67 | "block-spacing": "error",
68 | "brace-style": "error",
69 | "comma-spacing": [
70 | "error",
71 | {
72 | "before": false,
73 | "after": true
74 | }
75 | ],
76 | "indent": [
77 | "error",
78 | 2,
79 | {
80 | "SwitchCase": 1
81 | }
82 | ],
83 | "space-before-function-paren": [
84 | "error",
85 | "never"
86 | ],
87 | "space-before-blocks": "error",
88 | "prefer-const": "error",
89 | "no-var": "error",
90 | "arrow-body-style": "off",
91 | "arrow-spacing": "error",
92 | "strict": [
93 | "error"
94 | ],
95 | "no-warning-comments": [
96 | "warn",
97 | {
98 | "terms": [
99 | "todo",
100 | "fixme",
101 | "hack"
102 | ],
103 | "location": "anywhere"
104 | }
105 | ],
106 | "semi": [
107 | "error"
108 | ],
109 | "sort-imports": 0,
110 | "import/order": [2, {
111 | "groups": ["type", "builtin", "external", "internal", "parent", "sibling", "index", "object"],
112 | "alphabetize": { "order": "asc", "caseInsensitive": true }
113 | }],
114 | "@typescript-eslint/no-non-null-assertion": "off"
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@technote-space/toc-generator",
3 | "version": "4.3.1",
4 | "description": "GitHub Action to generate TOC.",
5 | "keywords": [
6 | "github",
7 | "github actions",
8 | "toc"
9 | ],
10 | "homepage": "https://github.com/technote-space/toc-generator",
11 | "bugs": {
12 | "url": "https://github.com/technote-space/toc-generator/issues"
13 | },
14 | "repository": {
15 | "type": "git",
16 | "url": "https://github.com/technote-space/toc-generator.git"
17 | },
18 | "license": "MIT",
19 | "author": {
20 | "name": "Technote",
21 | "email": "technote.space@gmail.com",
22 | "url": "https://technote.space"
23 | },
24 | "files": [
25 | "lib",
26 | "action.yml"
27 | ],
28 | "scripts": {
29 | "build": "rm -rdf lib && rollup -c",
30 | "cover": "vitest run --coverage",
31 | "postinstall": "[ -n \"$CI\" ] || [ ! -f node_modules/.bin/husky ] || husky install",
32 | "lint": "eslint 'src/**/*.ts' --cache",
33 | "lint:fix": "eslint --fix 'src/**/*.ts'",
34 | "prepublishOnly": "[ -n \"$CI\" ] || [ ! -f node_modules/.bin/pinst ] || pinst --disable",
35 | "postpublish": "[ -n \"$CI\" ] || [ ! -f node_modules/.bin/pinst ] || pinst --enable",
36 | "release": "yarn release-ga --test",
37 | "test": "yarn lint && yarn typecheck && yarn cover",
38 | "typecheck": "tsc --noEmit",
39 | "update": "npm_config_yes=true npx npm-check-updates -u --timeout 100000 && yarn install && yarn upgrade && yarn audit"
40 | },
41 | "devDependencies": {
42 | "@actions/core": "^1.10.0",
43 | "@actions/github": "^5.1.1",
44 | "@commitlint/cli": "^17.3.0",
45 | "@commitlint/config-conventional": "^17.3.0",
46 | "@rollup/plugin-commonjs": "^23.0.4",
47 | "@rollup/plugin-json": "^5.0.2",
48 | "@rollup/plugin-node-resolve": "^15.0.1",
49 | "@rollup/plugin-typescript": "^10.0.1",
50 | "@sindresorhus/tsconfig": "^3.0.1",
51 | "@technote-space/doctoc": "^2.6.1",
52 | "@technote-space/github-action-helper": "^5.3.10",
53 | "@technote-space/github-action-log-helper": "^0.2.9",
54 | "@technote-space/github-action-pr-helper": "^2.4.0",
55 | "@technote-space/github-action-test-helper": "^0.11.1",
56 | "@technote-space/release-github-actions-cli": "^1.9.3",
57 | "@types/node": "^18.11.13",
58 | "@typescript-eslint/eslint-plugin": "^5.46.0",
59 | "@typescript-eslint/parser": "^5.46.0",
60 | "@vitest/coverage-c8": "^0.25.7",
61 | "eslint": "^8.29.0",
62 | "eslint-plugin-import": "^2.26.0",
63 | "fast-glob": "^3.2.12",
64 | "husky": "^8.0.2",
65 | "lint-staged": "^13.1.0",
66 | "nock": "^13.2.9",
67 | "pinst": "^3.0.0",
68 | "rollup": "^3.7.2",
69 | "typescript": "^4.9.4",
70 | "vitest": "^0.25.7"
71 | },
72 | "publishConfig": {
73 | "access": "public"
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/.github/workflows/update-dependencies.yml:
--------------------------------------------------------------------------------
1 | on:
2 | schedule:
3 | - cron: 23 23 * * 5
4 | pull_request:
5 | types: [opened, reopened, closed]
6 | repository_dispatch:
7 | types: [update-deps]
8 | workflow_dispatch:
9 |
10 | concurrency:
11 | group: ${{ github.workflow }}-${{ github.ref }}
12 |
13 | name: Update dependencies
14 | jobs:
15 | update:
16 | name: Update npm dependencies
17 | runs-on: ubuntu-latest
18 | timeout-minutes: 10
19 | if: "! startsWith(github.head_ref, 'release/v')"
20 | steps:
21 | - name: Set running flag
22 | run: echo "RUNNING1=" >> $GITHUB_ENV
23 | - name: Set running flag
24 | run: echo "RUNNING1=1" >> $GITHUB_ENV
25 | if: github.event.pull_request.head.user.id == github.event.pull_request.base.user.id
26 | - uses: technote-space/load-config-action@v1
27 | if: env.RUNNING1
28 | with:
29 | CONFIG_FILENAME: workflow-settings.json, workflow-details.json
30 | IGNORE_WARNING: 'true'
31 | - name: Update dependencies
32 | if: env.RUNNING1
33 | id: update_deps
34 | uses: technote-space/create-pr-action@v2
35 | with:
36 | GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
37 | EXECUTE_COMMANDS: |
38 | npx npm-check-updates -u --packageFile package.json
39 | yarn install
40 | yarn upgrade
41 | yarn audit
42 | COMMIT_MESSAGE: 'chore: update npm dependencies'
43 | PR_DEFAULT_BRANCH_PREFIX: release/
44 | PR_DEFAULT_BRANCH_NAME: next-${CURRENT_VERSION}
45 | PR_DEFAULT_BRANCH_TITLE: 'feat: release'
46 | TARGET_BRANCH_PREFIX: release/
47 | AUTO_MERGE_THRESHOLD_DAYS: 14
48 |
49 | - name: Set running flag
50 | run: echo "RUNNING2=" >> $GITHUB_ENV
51 | - name: Set running flag
52 | run: echo "RUNNING2=1" >> $GITHUB_ENV
53 | if: env.RUNNING1 && steps.update_deps.outputs.result != 'succeeded' && github.event_name == 'pull_request' && github.event.action != 'closed' && startsWith(github.head_ref, 'release/')
54 | - uses: actions/checkout@v3
55 | if: env.RUNNING2
56 | - name: Set running flag
57 | run: |
58 | if [[ ! -f package.json ]] || [[ $(< package.json jq -r '.version == null') == 'true' ]]; then
59 | echo "RUNNING2=" >> $GITHUB_ENV
60 | fi
61 | - name: Sort
62 | run: npx sort-package-json
63 | if: env.RUNNING2
64 | - name: Get version
65 | uses: technote-space/get-next-version-action@v1
66 | with:
67 | EXCLUDE_MESSAGES: ${{ env.EXCLUDE_MESSAGES }}
68 | if: "env.RUNNING2 && ! startsWith(github.head_ref, 'release/v')"
69 | - name: Get version
70 | run: echo "NEXT_VERSION=${HEAD_REF#release/}" >> $GITHUB_ENV
71 | env:
72 | HEAD_REF: ${{ github.head_ref }}
73 | if: env.RUNNING2 && startsWith(github.head_ref, 'release/v')
74 | - name: Check package version
75 | uses: technote-space/package-version-check-action@v1
76 | with:
77 | GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
78 | BRANCH_PREFIX: release/
79 | NEXT_VERSION: ${{ env.NEXT_VERSION }}
80 | if: env.NEXT_VERSION
81 |
--------------------------------------------------------------------------------
/.github/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, sex characteristics, gender identity and expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at technote.space@gmail.com. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 | For answers to common questions about this code of conduct, see
76 | https://www.contributor-covenant.org/faq
77 |
--------------------------------------------------------------------------------
/src/utils/misc.ts:
--------------------------------------------------------------------------------
1 | import type { ExecuteTask, MainArguments } from '@technote-space/github-action-pr-helper/dist/types';
2 | import os from 'os';
3 | import { resolve, join } from 'path';
4 | import { getInput } from '@actions/core' ;
5 | import { Utils } from '@technote-space/github-action-helper';
6 | import { Logger } from '@technote-space/github-action-log-helper';
7 | import { ACTION_NAME, ACTION_OWNER, ACTION_REPO, TARGET_EVENTS } from '../constant';
8 | import { doctoc } from './doctoc';
9 |
10 | export const replaceDirectory = (message: string): string => {
11 | const workDir = resolve(Utils.getWorkspace());
12 | return [
13 | { key: ` -C ${workDir}`, value: '' },
14 | { key: workDir, value: '[Working Directory]' },
15 | ].reduce((value, target) => Utils.replaceAll(value, target.key, target.value), message);
16 | };
17 |
18 | const getTargetPaths = (): Array => Utils.getArrayInput('TARGET_PATHS', true).filter(target => target && !target.startsWith('/') && !target.includes('..'));
19 | const getTocTitle = (): string => getInput('TOC_TITLE');
20 |
21 | export const isNoTitle = (title: string): boolean => '' === title;
22 | export const isFolding = (): boolean => Utils.getBoolValue(getInput('FOLDING'));
23 | export const getMaxHeaderLevel = (): number | undefined => /^\d+$/.test(getInput('MAX_HEADER_LEVEL')) ? Number.parseInt(getInput('MAX_HEADER_LEVEL')) : undefined;
24 | export const getEntryPrefix = (): string => getInput('ENTRY_PREFIX');
25 |
26 | const getExecuteCommands = (logger: Logger): Array => {
27 | const paths = getTargetPaths();
28 | if (!paths.length) {
29 | logger.warn('There is no valid target. Please check if [TARGET_PATHS] is set correctly.');
30 | return [];
31 | }
32 |
33 | const title = getTocTitle().replace('\'', '\\\'').replace('"', '\\"');
34 |
35 | return [doctoc(paths, title, logger)];
36 | };
37 |
38 | export const getRunnerArguments = (): MainArguments => {
39 | const logger = new Logger(replaceDirectory);
40 | return {
41 | rootDir: resolve(__dirname, '..'),
42 | logger,
43 | actionName: ACTION_NAME,
44 | actionOwner: ACTION_OWNER,
45 | actionRepo: ACTION_REPO,
46 | executeCommands: getExecuteCommands(logger),
47 | commitMessage: getInput('COMMIT_MESSAGE'),
48 | commitName: getInput('COMMIT_NAME'),
49 | commitEmail: getInput('COMMIT_EMAIL'),
50 | prBranchPrefix: getInput('PR_BRANCH_PREFIX'),
51 | prBranchName: getInput('PR_BRANCH_NAME'),
52 | prTitle: getInput('PR_TITLE'),
53 | prBody: getInput('PR_BODY'),
54 | prBranchPrefixForDefaultBranch: getInput('PR_DEFAULT_BRANCH_PREFIX'),
55 | prBranchNameForDefaultBranch: getInput('PR_DEFAULT_BRANCH_NAME'),
56 | prTitleForDefaultBranch: getInput('PR_DEFAULT_BRANCH_TITLE'),
57 | prBodyForDefaultBranch: getInput('PR_DEFAULT_BRANCH_BODY'),
58 | prBodyForComment: getInput('PR_COMMENT_BODY'),
59 | prCloseMessage: getInput('PR_CLOSE_MESSAGE'),
60 | filterGitStatus: 'M',
61 | filterExtensions: ['md', 'markdown'],
62 | targetBranchPrefix: getInput('TARGET_BRANCH_PREFIX'),
63 | includeLabels: Utils.getArrayInput('INCLUDE_LABELS'),
64 | targetEvents: TARGET_EVENTS,
65 | notCreatePr: !Utils.getBoolValue(getInput('CREATE_PR')),
66 | checkOnlyDefaultBranch: Utils.getBoolValue(getInput('CHECK_ONLY_DEFAULT_BRANCH')),
67 | signoff: Utils.getBoolValue(getInput('SIGNOFF')),
68 | };
69 | };
70 |
71 | // eslint-disable-next-line no-magic-numbers
72 | export const homeExpanded = (path: string): string => path.indexOf('~') === 0 ? join(os.homedir(), path.substr(1)) : resolve(Utils.getWorkspace(), path);
73 | export const cleanPath = (path: string): string => homeExpanded(path).replace(/\s/g, '\\ ');
74 |
75 | // to avoid removing space
76 | const getRawInput = (name: string): string => String(process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`]);
77 | export const getArrayInput = (name: string): Array => Utils.uniqueArray(getRawInput(name).split(/\r?\n/).filter(item => item));
78 |
--------------------------------------------------------------------------------
/.github/workflows/pr-updated.yml:
--------------------------------------------------------------------------------
1 | on: pull_request_target
2 |
3 | concurrency:
4 | group: ${{ github.workflow }}-${{ github.ref }}
5 |
6 | name: Pull Request updated
7 |
8 | jobs:
9 | triage:
10 | name: Pull Request Labeler
11 | runs-on: ubuntu-latest
12 | timeout-minutes: 3
13 | if: "! startsWith(github.head_ref, 'release/')"
14 | steps:
15 | - uses: actions/labeler@v2
16 | with:
17 | repo-token: ${{ secrets.GITHUB_TOKEN }}
18 |
19 | history:
20 | name: Pull Request Body
21 | runs-on: ubuntu-latest
22 | timeout-minutes: 3
23 | if: github.event.pull_request.head.user.id == github.event.pull_request.base.user.id
24 | steps:
25 | - uses: technote-space/load-config-action@v1
26 | with:
27 | CONFIG_FILENAME: workflow-settings.json, workflow-details.json
28 | IGNORE_WARNING: 'true'
29 | - uses: technote-space/pr-commit-body-action@v1
30 | with:
31 | EXCLUDE_MESSAGES: ${{ env.EXCLUDE_MESSAGES }}
32 | TITLE: ${{ env.PR_BODY_TITLE }}
33 | LINK_ISSUE_KEYWORD: ${{ (startsWith(github.head_ref, 'release/') && 'closes') || '' }}
34 | FILTER_PR: true
35 | CHANGE_TEMPLATE: ${{ env.CHANGE_TEMPLATE }}
36 |
37 | manageRelease:
38 | name: Manage release
39 | runs-on: ubuntu-latest
40 | timeout-minutes: 3
41 | if: "github.event.pull_request.head.user.id == github.event.pull_request.base.user.id && startsWith(github.head_ref, 'release/') && ! startsWith(github.head_ref, 'release/v')"
42 | steps:
43 | - uses: technote-space/load-config-action@v1
44 | with:
45 | CONFIG_FILENAME: workflow-settings.json, workflow-details.json
46 | IGNORE_WARNING: 'true'
47 | - uses: technote-space/release-type-action@v1
48 | with:
49 | EXCLUDE_MESSAGES: ${{ env.EXCLUDE_MESSAGES }}
50 | GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
51 |
52 | checkVersion:
53 | name: Check package version
54 | runs-on: ubuntu-latest
55 | timeout-minutes: 3
56 | if: "github.event.action == 'synchronize' && github.event.pull_request.head.user.id == github.event.pull_request.base.user.id && startsWith(github.head_ref, 'release/')"
57 | steps:
58 | - uses: technote-space/load-config-action@v1
59 | with:
60 | CONFIG_FILENAME: workflow-settings.json, workflow-details.json
61 | IGNORE_WARNING: 'true'
62 | - name: Set running flag
63 | run: echo "RUNNING=1" >> $GITHUB_ENV
64 | - uses: actions/checkout@v3
65 | with:
66 | ref: ${{ github.head_ref }}
67 | - name: Set running flag
68 | run: |
69 | if [[ ! -f package.json ]] || [[ $(< package.json jq -r '.version == null') == 'true' ]]; then
70 | echo "RUNNING=" >> $GITHUB_ENV
71 | fi
72 |
73 | - name: Sort
74 | run: npx sort-package-json
75 | if: env.RUNNING
76 | - name: Get version
77 | uses: technote-space/get-next-version-action@v1
78 | with:
79 | EXCLUDE_MESSAGES: ${{ env.EXCLUDE_MESSAGES }}
80 | if: "env.RUNNING && ! startsWith(github.head_ref, 'release/v')"
81 | - name: Get version
82 | run: echo "NEXT_VERSION=${HEAD_REF#release/}" >> $GITHUB_ENV
83 | env:
84 | HEAD_REF: ${{ github.head_ref }}
85 | if: env.RUNNING && startsWith(github.head_ref, 'release/v')
86 | - name: Check package version
87 | uses: technote-space/package-version-check-action@v1
88 | with:
89 | GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
90 | BRANCH_PREFIX: release/
91 | NEXT_VERSION: ${{ env.NEXT_VERSION }}
92 | if: env.NEXT_VERSION
93 |
94 | checkPublish:
95 | name: Check publish
96 | runs-on: ubuntu-latest
97 | timeout-minutes: 3
98 | if: "github.event.pull_request.head.user.id == github.event.pull_request.base.user.id && startsWith(github.head_ref, 'release/')"
99 | steps:
100 | - name: Set running flag
101 | run: echo "RUNNING=1" >> $GITHUB_ENV
102 | - name: Set running flag
103 | run: |
104 | if [ -z "$NPM_AUTH_TOKEN" ]; then
105 | echo "RUNNING=" >> $GITHUB_ENV
106 | fi
107 | env:
108 | NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
109 |
110 | - uses: actions/checkout@v3
111 | with:
112 | ref: ${{ github.head_ref }}
113 | if: env.RUNNING
114 | - uses: technote-space/can-npm-publish-action@v1
115 | if: env.RUNNING
116 |
--------------------------------------------------------------------------------
/action.yml:
--------------------------------------------------------------------------------
1 | name: TOC Generator
2 |
3 | description: GitHub Action to generate TOC.
4 |
5 | author: technote-space
6 |
7 | inputs:
8 | GITHUB_TOKEN:
9 | description: Secret GitHub API token used to make API requests or git authentication.
10 | default: ${{ github.token }}
11 | required: false
12 | API_TOKEN:
13 | description: Secret GitHub API token used to make API requests.
14 | required: false
15 | SIGNOFF:
16 | description: 'Add `Signed-off-by` line by the committer at the end of the commit log message.'
17 | required: false
18 |
19 | TARGET_PATHS:
20 | description: Target file path. (Comma separated, @see https://github.com/thlorenz/doctoc#adding-toc-to-individual-files)
21 | default: 'README*.md'
22 | required: false
23 | TOC_TITLE:
24 | description: TOC Title
25 | default: '**Table of Contents**'
26 | required: false
27 | FOLDING:
28 | description: Whether to fold.
29 | required: false
30 | MAX_HEADER_LEVEL:
31 | description: Max header level.
32 | required: false
33 | ENTRY_PREFIX:
34 | description: Entry prefix.
35 | required: false
36 | OPENING_COMMENT:
37 | description: Opening comment (for other than DocToc)
38 | required: false
39 | default: '
16 |
17 |
18 | Details
19 |
20 | - [Installation](#installation)
21 | - [Screenshot](#screenshot)
22 | - [Options](#options)
23 | - [Specify options individually](#specify-options-individually)
24 | - [Action event details](#action-event-details)
25 | - [Target event](#target-event)
26 | - [Conditions](#conditions)
27 | - [Addition](#addition)
28 | - [GITHUB_TOKEN](#github_token)
29 | - [Create PullRequest](#create-pullrequest)
30 | - [Context variables](#context-variables)
31 | - [Context PR variables](#context-pr-variables)
32 | - [Configuration Examples](#configuration-examples)
33 | - [Example 1](#example-1)
34 | - [Example 2](#example-2)
35 | - [Example 3](#example-3)
36 | - [Author](#author)
37 |
38 |
39 |
40 |
41 | ## 安装
42 | 1. 指定 TOC 位置(可选)
43 | 示例 `README.md`
44 | ```markdown
45 |
46 |
47 | ```
48 | [详情](https://github.com/thlorenz/doctoc#specifying-location-of-toc)
49 | 1. 创建 workflow
50 | 示例 `.github/workflows/toc.yml`
51 | ```yaml
52 | on: push
53 | name: TOC Generator
54 | jobs:
55 | generateTOC:
56 | name: TOC Generator
57 | runs-on: ubuntu-latest
58 | steps:
59 | - uses: technote-space/toc-generator@v4
60 | ```
61 |
62 | ## 截图
63 | 
64 |
65 | ## 选项
66 | | 名称 | 描述 | 默认值 | 示例 |
67 | |:---|:---|:---|:---|
68 | |TARGET_PATHS|Target file path. (Comma separated, [Detail](https://github.com/thlorenz/doctoc#adding-toc-to-individual-files))|`README*.md`|`README*.md,CHANGELOG.md`, `.`|
69 | |TOC_TITLE|TOC Title|`**Table of Contents**`|`''`|
70 | |MAX_HEADER_LEVEL|Maximum heading level. ([Detail](https://github.com/thlorenz/doctoc#specifying-a-maximum-heading-level-for-toc-entries))| |`3`|
71 | |CUSTOM_MODE|Whether it is custom mode([Generated Example](samples/README.horizontal.md))|`false`|`true`|
72 | |CUSTOM_TEMPLATE|Custom template for custom mode|`${ITEMS}
`| |
73 | |ITEM_TEMPLATE|Item template for custom mode|`${TEXT}`| |
74 | |SEPARATOR|Separator for custom mode|\|\| |
75 | |FOLDING|Whether to make TOC foldable|`false`|`true`|
76 | |COMMIT_MESSAGE|Commit message|`chore(docs): update TOC`|`docs: update TOC`|
77 | |COMMIT_NAME|Git commit name|`${github.actor}`| |
78 | |COMMIT_EMAIL|Git commit email|`${github.actor}@users.noreply.github.com`| |
79 | |CREATE_PR|Whether to create PullRequest|`false`|`true`|
80 | |CHECK_ONLY_DEFAULT_BRANCH|Whether to check only default branch|`false`|`true`|
81 | |PR_BRANCH_PREFIX|PullRequest branch prefix|`toc-generator/`| |
82 | |PR_BRANCH_NAME|PullRequest branch name
[Context variables](#context-variables)|`update-toc-${PR_ID}`|`toc-${PR_NUMBER}`|
83 | |PR_TITLE|PullRequest title
[Context variables](#context-variables)|`chore(docs): update TOC (${PR_MERGE_REF})`|`docs: update TOC`|
84 | |PR_BODY|PullRequest body
[Context PR variables](#context-pr-variables)|[action.yml](action.yml)| |
85 | |PR_COMMENT_BODY|PullRequest body for comment
[Context PR variables](#context-pr-variables)|[action.yml](action.yml)| |
86 | |PR_CLOSE_MESSAGE|Message body when closing PullRequest|`This PR has been closed because it is no longer needed.`| |
87 | |TARGET_BRANCH_PREFIX|Filter by branch name| |`release/`|
88 | |INCLUDE_LABELS|Labels used to check if the PullRequest has it| |`Label1, Label2`|
89 | |OPENING_COMMENT|Opening comment (for other than DocToc)|`
102 |
103 |
104 |
105 |
106 |
107 | ...
108 |
109 | ```
110 |
111 | ## Action 事件详情
112 | ### 目标事件
113 | | eventName: action | condition |
114 | |:---|:---|
115 | |push: *|[condition1](#condition1)|
116 | |pull_request: \[opened, synchronize, reopened, labeled, unlabeled]|[condition2](#condition2)|
117 | |pull_request: \[closed]||
118 | |schedule, repository_dispatch, workflow_dispatch||
119 |
120 | - 以下活动类型必须明确指定 ([详情](https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#pull-request-event-pull_request))
121 | - `labeled`, `unlabeled`, `closed`
122 | ### 条件
123 | #### condition1
124 | - 推送到分支 (不是tag)
125 | - 分支名称 ([`TARGET_BRANCH_PREFIX`](#options))
126 | #### condition2
127 | - 包含指定标签? ([`INCLUDE_LABELS`](#options))
128 | - 分支名称 ([`TARGET_BRANCH_PREFIX`](#options))
129 |
130 | ## 附加说明
131 | ### GITHUB_TOKEN
132 | `GITHUB_TOKEN` 作为 `GitHub Actions` 的一部分,没有授权来创建任何后续事件。
133 | 因此它不会产生由推送触发的 action 。
134 |
135 | 如果你配置了分支保护策略,这会是个问题。
136 |
137 | 如果你想触发 action,使用个人访问令牌来代替。
138 | 1. 生成一个 [个人访问令牌](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line) ,范围需选择 public_repo 或 repo 。
139 | (私有仓库必须选择 repo)。
140 | 1. [保存为ACCESS_TOKEN](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets)
141 | 1. 使用 `ACCESS_TOKEN` 代替 `GITHUB_TOKEN` 作为输入。
142 | 示例 `.github/workflows/toc.yml`
143 | ```yaml
144 | on: push
145 | name: TOC Generator
146 | jobs:
147 | generateTOC:
148 | name: TOC Generator
149 | runs-on: ubuntu-latest
150 | steps:
151 | - uses: technote-space/toc-generator@v4
152 | with:
153 | GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
154 | ```
155 |
156 | ### 创建 PullRequest
157 | 如果 `CREATE_PR` 设置为 `true`,则会创建一个 PR 。
158 |
159 | ```yaml
160 | on: pull_request
161 | name: TOC Generator
162 | jobs:
163 | generateTOC:
164 | name: TOC Generator
165 | runs-on: ubuntu-latest
166 | steps:
167 | - uses: technote-space/toc-generator@v4
168 | with:
169 | CREATE_PR: true
170 | ```
171 |
172 | 
173 |
174 | 如果活动类型设置为 `closed`,则该 action 会在 PR 不再需要时关闭它 。
175 |
176 | ```yaml
177 | on:
178 | pull_request:
179 | types: [opened, synchronize, reopened, closed]
180 | name: TOC Generator
181 | jobs:
182 | generateTOC:
183 | name: TOC Generator
184 | runs-on: ubuntu-latest
185 | steps:
186 | - uses: technote-space/toc-generator@v4
187 | ```
188 |
189 | ### 上下文变量
190 | | 名称 | 描述 |
191 | |:---|:---|
192 | | PR_NUMBER | pull_request.number (如 `11`) |
193 | | PR_NUMBER_REF | `#${pull_request.number}` (如 `#11`) |
194 | | PR_ID | pull_request.id (如 `21031067`) |
195 | | PR_HEAD_REF | pull_request.head.ref (如 `change`) |
196 | | PR_BASE_REF | pull_request.base.ref (如 `main`) |
197 | | PR_MERGE_REF | pull_request.base.ref (如 `change -> main`) |
198 | | PR_TITLE | pull_request.title (如 `update the README with new information.`) |
199 |
200 | [Payload 示例](https://developer.github.com/v3/activity/events/types/#webhook-payload-example-28)
201 |
202 | ### 上下文 PR 变量
203 | - [上下文变量](#context-variables)
204 |
205 | | 名称 | 描述 |
206 | |:---|:---|
207 | | PR_LINK | PR 链接 |
208 | | COMMANDS_OUTPUT | TOC 命令结果 |
209 | | FILES_SUMMARY | 如 `Changed 2 files` |
210 | | FILES | 变更文件列表 |
211 |
212 | ## 配置示例 Examples
213 | ### 示例 1
214 | 在没有限制的分支上push时执行 action 并直接提交。
215 |
216 | ```yaml
217 | on: push
218 | name: TOC Generator
219 | jobs:
220 | generateTOC:
221 | name: TOC Generator
222 | runs-on: ubuntu-latest
223 | steps:
224 | - uses: technote-space/toc-generator@v4
225 | ```
226 |
227 | ### 示例 2
228 | 通过仅对以 `release/` 开头的分支执行 PR 更新操作,从而创建或更新 PR。
229 |
230 | ```yaml
231 | on:
232 | pull_request:
233 | types: [opened, synchronize, reopened, closed]
234 | name: TOC Generator
235 | jobs:
236 | generateTOC:
237 | name: TOC Generator
238 | runs-on: ubuntu-latest
239 | steps:
240 | - uses: technote-space/toc-generator@v4
241 | with:
242 | CREATE_PR: true
243 | TARGET_BRANCH_PREFIX: release/
244 | ```
245 |
246 | ### 示例 3
247 | 仅在默认分支定时执行action并直接提交。
248 | (使用为其他 workflow 运行而创建的 Token)
249 |
250 | ```yaml
251 | on:
252 | schedule:
253 | - cron: "0 23 * * *"
254 | name: TOC Generator
255 | jobs:
256 | generateTOC:
257 | name: TOC Generator
258 | runs-on: ubuntu-latest
259 | steps:
260 | - uses: technote-space/toc-generator@v4
261 | with:
262 | GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
263 | CHECK_ONLY_DEFAULT_BRANCH: true
264 | ```
265 |
266 | ## 作者
267 | [GitHub (Technote)](https://github.com/technote-space)
268 | [博客](https://technote.space)
269 |
--------------------------------------------------------------------------------
/README.ja.md:
--------------------------------------------------------------------------------
1 | # TOC Generator
2 |
3 | [](https://github.com/technote-space/toc-generator/actions)
4 | [](https://codecov.io/gh/technote-space/toc-generator)
5 | [](https://www.codefactor.io/repository/github/technote-space/toc-generator)
6 | [](https://github.com/technote-space/toc-generator/blob/main/LICENSE)
7 |
8 | *Read this in other languages: [English](README.md), [日本語](README.ja.md).*
9 |
10 | これは目次を生成する`GitHub Actions`です。
11 | [DocToc](https://github.com/thlorenz/doctoc) を実行し変更があればコミットします。
12 |
13 | ## Table of Contents
14 |
15 |
16 |
17 |
18 | Details
19 |
20 | - [インストール](#%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB)
21 | - [スクリーンショット](#%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)
22 | - [オプション](#%E3%82%AA%E3%83%97%E3%82%B7%E3%83%A7%E3%83%B3)
23 | - [個別に指定](#%E5%80%8B%E5%88%A5%E3%81%AB%E6%8C%87%E5%AE%9A)
24 | - [Action イベント詳細](#action-%E3%82%A4%E3%83%99%E3%83%B3%E3%83%88%E8%A9%B3%E7%B4%B0)
25 | - [対象イベント](#%E5%AF%BE%E8%B1%A1%E3%82%A4%E3%83%99%E3%83%B3%E3%83%88)
26 | - [Conditions](#conditions)
27 | - [補足](#%E8%A3%9C%E8%B6%B3)
28 | - [GITHUB_TOKEN](#github_token)
29 | - [プルリクエストの作成](#%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)
30 | - [Context variables](#context-variables)
31 | - [Context PR variables](#context-pr-variables)
32 | - [設定例](#%E8%A8%AD%E5%AE%9A%E4%BE%8B)
33 | - [例1](#%E4%BE%8B%EF%BC%91)
34 | - [例2](#%E4%BE%8B%EF%BC%92)
35 | - [例3](#%E4%BE%8B%EF%BC%93)
36 | - [Author](#author)
37 |
38 |
39 |
40 |
41 | ## インストール
42 | 1. 目次の位置を指定 (option)
43 | ```markdown
44 |
45 |
46 | ```
47 | [詳細](https://github.com/thlorenz/doctoc#specifying-location-of-toc)
48 | 1. workflow を設定
49 | 例:`.github/workflows/toc.yml`
50 | ```yaml
51 | on: push
52 | name: TOC Generator
53 | jobs:
54 | generateTOC:
55 | name: TOC Generator
56 | runs-on: ubuntu-latest
57 | steps:
58 | - uses: technote-space/toc-generator@v4
59 | ```
60 |
61 | ## スクリーンショット
62 | 
63 |
64 | ## オプション
65 | | name | description | default | e.g. |
66 | |:---|:---|:---|:---|
67 | |TARGET_PATHS|対象のファイルパス (カンマ区切り, [詳細](https://github.com/thlorenz/doctoc#adding-toc-to-individual-files))|`README*.md`|`README*.md,CHANGELOG.md`, `.`|
68 | |TOC_TITLE|目次タイトル|`**Table of Contents**`|`''`|
69 | |MAX_HEADER_LEVEL|Heading最大レベル ([詳細](https://github.com/thlorenz/doctoc#specifying-a-maximum-heading-level-for-toc-entries))| |`3`|
70 | |CUSTOM_MODE|Customモードかどうか([生成例](samples/README.horizontal.md))|`false`|`true`|
71 | |CUSTOM_TEMPLATE|Customテンプレート(Customモード)|`${ITEMS}
`| |
72 | |ITEM_TEMPLATE|アイテムテンプレート(Customモード)|`${TEXT}`| |
73 | |SEPARATOR|セパレータ(Customモード)|\|\| |
74 | |FOLDING|目次を折りたたみ式にするかどうか|`false`|`true`|
75 | |COMMIT_MESSAGE|コミットメッセージ|`chore(docs): update TOC`|`docs: update TOC`|
76 | |COMMIT_NAME|コミット時に設定する名前|`${github.actor}`| |
77 | |COMMIT_EMAIL|コミット時に設定するメールアドレス|`${github.actor}@users.noreply.github.com`| |
78 | |CREATE_PR|プルリクエストを作成するかどうか|`false`|`true`|
79 | |CHECK_ONLY_DEFAULT_BRANCH|デフォルトのブランチのみをチェックするかどうか|`false`|`true`|
80 | |PR_BRANCH_PREFIX|プルリクエストのブランチプリフィックス|`toc-generator/`| |
81 | |PR_BRANCH_NAME|プルリクエストのブランチ名
[Context variables](#context-variables)|`update-toc-${PR_ID}`|`toc-${PR_NUMBER}`|
82 | |PR_TITLE|プルリクエストのタイトル
[Context variables](#context-variables)|`chore(docs): update TOC (${PR_MERGE_REF})`|`docs: update TOC`|
83 | |PR_BODY|プルリクエストの本文
[Context PR variables](#context-pr-variables)|[action.yml](action.yml)| |
84 | |PR_COMMENT_BODY|プルリクエストの本文(コメント用)
[Context PR variables](#context-pr-variables)|[action.yml](action.yml)| |
85 | |PR_CLOSE_MESSAGE|プルリクエストを閉じるときのメッセージ|`This PR has been closed because it is no longer needed.`| |
86 | |TARGET_BRANCH_PREFIX|ブランチ名のフィルタ| |`release/`|
87 | |INCLUDE_LABELS|プルリクエストに付与されているかチェックするラベル| |`Label1, Label2`|
88 | |OPENING_COMMENT|開始コメント (DocToc以外のため)|`
101 |
102 |
103 |
104 |
105 |
106 | ...
107 |
108 | ```
109 |
110 | ## Action イベント詳細
111 | ### 対象イベント
112 | | eventName: action | condition |
113 | |:---|:---|
114 | |push: *|[condition1](#condition1)|
115 | |pull_request: \[opened, synchronize, reopened, labeled, unlabeled]|[condition2](#condition2)|
116 | |pull_request: \[closed]||
117 | |schedule, repository_dispatch, workflow_dispatch||
118 |
119 | - 次のアクティビティタイプは明示的に指定する必要があります。 ([詳細](https://help.github.com/ja/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#pull-request-event-pull_request))
120 | - `labeled`, `unlabeled`, `closed`
121 | ### Conditions
122 | #### condition1
123 | - ブランチへのプッシュ (タグのプッシュではない)
124 | - ブランチ名 ([`TARGET_BRANCH_PREFIX`](#%E3%82%AA%E3%83%97%E3%82%B7%E3%83%A7%E3%83%B3))
125 | #### condition2
126 | - 指定したラベルが付与されているかどうか ([`INCLUDE_LABELS`](#%E3%82%AA%E3%83%97%E3%82%B7%E3%83%A7%E3%83%B3))
127 | - ブランチ名 ([`TARGET_BRANCH_PREFIX`](#%E3%82%AA%E3%83%97%E3%82%B7%E3%83%A7%E3%83%B3))
128 |
129 | ## 補足
130 | ### GITHUB_TOKEN
131 | GitHub Actions で提供される`GITHUB_TOKEN`は連続するイベントを作成する権限がありません。
132 | したがって、プッシュによってトリガーされるビルドアクションなどは実行されません。
133 |
134 | これはブランチプロテクションを設定していると問題になる場合があります。
135 |
136 | もしアクションをトリガーしたい場合は代わりに`personal access token`を使用してください。
137 | 1. public_repo または repo の権限で [Personal access token](https://help.github.com/ja/articles/creating-a-personal-access-token-for-the-command-line) を生成
138 | (repo はプライベートリポジトリで必要です)
139 | 1. [ACCESS_TOKENとして保存](https://help.github.com/ja/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets)
140 | 1. `GITHUB_TOKEN`の代わりに`ACCESS_TOKEN`を使用するように設定
141 | 例:`.github/workflows/toc.yml`
142 | ```yaml
143 | on: push
144 | name: TOC Generator
145 | jobs:
146 | generateTOC:
147 | name: TOC Generator
148 | runs-on: ubuntu-latest
149 | steps:
150 | - uses: technote-space/toc-generator@v4
151 | with:
152 | GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
153 | ```
154 |
155 | ### プルリクエストの作成
156 | `CREATE_PR` に `true` を設定した場合は、プルリクエストが作成されます。
157 |
158 | ```yaml
159 | on: pull_request
160 | name: TOC Generator
161 | jobs:
162 | generateTOC:
163 | name: TOC Generator
164 | runs-on: ubuntu-latest
165 | steps:
166 | - uses: technote-space/toc-generator@v4
167 | with:
168 | CREATE_PR: true
169 | ```
170 |
171 | 
172 |
173 | `closed`アクティビティタイプが設定されている場合、このアクションは不要になったプルリクエストを閉じます。
174 |
175 | ```yaml
176 | on:
177 | pull_request:
178 | types: [opened, synchronize, reopened, closed]
179 | name: TOC Generator
180 | jobs:
181 | generateTOC:
182 | name: TOC Generator
183 | runs-on: ubuntu-latest
184 | steps:
185 | - uses: technote-space/toc-generator@v4
186 | ```
187 |
188 | ### Context variables
189 | | name | description |
190 | |:---|:---|
191 | | PR_NUMBER | pull_request.number (例:`11`) |
192 | | PR_NUMBER_REF | `#${pull_request.number}` (例:`#11`) |
193 | | PR_ID | pull_request.id (例:`21031067`) |
194 | | PR_HEAD_REF | pull_request.head.ref (例:`change`) |
195 | | PR_BASE_REF | pull_request.base.ref (例:`main`) |
196 | | PR_MERGE_REF | pull_request.base.ref (例:`change -> main`) |
197 | | PR_TITLE | pull_request.title (例:`update the README with new information.`) |
198 |
199 | [Payload example](https://developer.github.com/v3/activity/events/types/#webhook-payload-example-28)
200 |
201 | ### Context PR variables
202 | - [Context variables](#context-variables)
203 |
204 | | name | description |
205 | |:---|:---|
206 | | PR_LINK | プルリクエストへのリンク |
207 | | COMMANDS_OUTPUT | TOC コマンドの結果 |
208 | | FILES_SUMMARY | 例:`Changed 2 files` |
209 | | FILES | 変更されたファイル一覧 |
210 |
211 | ## 設定例
212 | ### 例1
213 | ブランチを制限しないでPush時にアクションを実行し直接コミット
214 |
215 | ```yaml
216 | on: push
217 | name: TOC Generator
218 | jobs:
219 | generateTOC:
220 | name: TOC Generator
221 | runs-on: ubuntu-latest
222 | steps:
223 | - uses: technote-space/toc-generator@v4
224 | ```
225 |
226 | ### 例2
227 | `release/` から始まるブランチのみを対象にPull Request更新時に実行しPull Requestを作成または更新
228 |
229 | ```yaml
230 | on:
231 | pull_request:
232 | types: [opened, synchronize, reopened, closed]
233 | name: TOC Generator
234 | jobs:
235 | generateTOC:
236 | name: TOC Generator
237 | runs-on: ubuntu-latest
238 | steps:
239 | - uses: technote-space/toc-generator@v4
240 | with:
241 | CREATE_PR: true
242 | TARGET_BRANCH_PREFIX: release/
243 | ```
244 |
245 | ### 例3
246 | デフォルトブランチのみを対象にスケジュールでアクションを実行し直接コミット
247 | (他のワークフローの起動のために作成したTokenを使用)
248 |
249 | ```yaml
250 | on:
251 | schedule:
252 | - cron: "0 23 * * *"
253 | name: TOC Generator
254 | jobs:
255 | generateTOC:
256 | name: TOC Generator
257 | runs-on: ubuntu-latest
258 | steps:
259 | - uses: technote-space/toc-generator@v4
260 | with:
261 | GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
262 | CHECK_ONLY_DEFAULT_BRANCH: true
263 | ```
264 |
265 | ## Author
266 | [GitHub (Technote)](https://github.com/technote-space)
267 | [Blog](https://technote.space)
268 |
--------------------------------------------------------------------------------
/samples/README.horizontal.md:
--------------------------------------------------------------------------------
1 | # TOC Generator
2 |
3 | [](https://github.com/technote-space/toc-generator/actions)
4 | [](https://codecov.io/gh/technote-space/toc-generator)
5 | [](https://www.codefactor.io/repository/github/technote-space/toc-generator)
6 | [](https://github.com/technote-space/toc-generator/blob/master/LICENSE)
7 |
8 | *Read this in other languages: [English](README.md), [日本語](README.ja.md).*
9 |
10 | This is a `GitHub Actions` to generate TOC (Table of Contents),
11 | which executes [DocToc](https://github.com/thlorenz/doctoc) and commits if changed.
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | Installation
21 | |
22 | Screenshot
23 | |
24 | Options
25 | |
26 | Action event details
27 | |
28 | Addition
29 | |
30 | Configuration Examples
31 | |
32 | Author
33 |
34 |
35 |
36 |
37 | ## Installation
38 | 1. Specify location of TOC (option)
39 | e.g. `README.md`
40 | ```markdown
41 |
42 |
43 | ```
44 | [detail](https://github.com/thlorenz/doctoc#specifying-location-of-toc)
45 | 1. Setup workflow
46 | e.g. `.github/workflows/toc.yml`
47 | ```yaml
48 | on: push
49 | name: TOC Generator
50 | jobs:
51 | generateTOC:
52 | name: TOC Generator
53 | runs-on: ubuntu-latest
54 | steps:
55 | - uses: technote-space/toc-generator@v3
56 | ```
57 |
58 | ## Screenshot
59 | 
60 |
61 | ## Options
62 | | name | description | default | required | e.g. |
63 | |:---:|:---|:---:|:---:|:---:|
64 | |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`, `.`|
65 | |TOC_TITLE|TOC Title|`**Table of Contents**`| |`''`|
66 | |MAX_HEADER_LEVEL|Maximum heading level. ([Detail](https://github.com/thlorenz/doctoc#specifying-a-maximum-heading-level-for-toc-entries))| | |`3`|
67 | |CUSTOM_MODE|Whether it is custom mode([Generated Example](./__tests__/fixtures/doctoc/expected/README.horizontal2.md))|`false`| |`true`|
68 | |CUSTOM_TEMPLATE|Custom template for custom mode|`${ITEMS}
`| | |
69 | |ITEM_TEMPLATE|Item template for custom mode|`${TEXT}`| | |
70 | |SEPARATOR|Separator for custom mode|\|\| | |
71 | |FOLDING|Whether to make TOC foldable([Generated Example](./__tests__/fixtures/doctoc/expected/README.update.wrap.md))|`false`| |`true`|
72 | |COMMIT_MESSAGE|Commit message|`chore(docs): update TOC`|true|`docs: update TOC`|
73 | |COMMIT_NAME|Git commit name|`${github.actor}`| | |
74 | |COMMIT_EMAIL|Git commit email|`${github.actor}@users.noreply.github.com`| | |
75 | |CREATE_PR|Whether to check only default branch|`false`| |`true`|
76 | |CHECK_ONLY_DEFAULT_BRANCH|Whether to create PullRequest|`false`| |`true`|
77 | |PR_BRANCH_PREFIX|PullRequest branch prefix|`toc-generator/`|true| |
78 | |PR_BRANCH_NAME|PullRequest branch name
[Context variables](#context-variables)|`update-toc-${PR_ID}`|true|`toc-${PR_NUMBER}`|
79 | |PR_TITLE|PullRequest title
[Context variables](#context-variables)|`chore(docs): update TOC (${PR_MERGE_REF})`|true|`docs: update TOC`|
80 | |PR_BODY|PullRequest body
[Context PR variables](#context-pr-variables)|[action.yml](action.yml)|true| |
81 | |PR_COMMENT_BODY|PullRequest body for comment
[Context PR variables](#context-pr-variables)|[action.yml](action.yml)| | |
82 | |PR_CLOSE_MESSAGE|Message body when closing PullRequest|`This PR has been closed because it is no longer needed.`| | |
83 | |TARGET_BRANCH_PREFIX|Filter by branch name| | |`release/`|
84 | |INCLUDE_LABELS|Labels used to check if the PullRequest has it| | |`Label1, Label2`|
85 | |OPENING_COMMENT|Opening comment (for other than DocToc)|`
16 |
17 |
18 |
19 |
20 | - [Installation](#installation)
21 | - [Screenshot](#screenshot)
22 | - [Options](#options)
23 | - [Action event details](#action-event-details)
24 | - [Target event](#target-event)
25 | - [Conditions](#conditions)
26 | - [Addition](#addition)
27 | - [GITHUB_TOKEN](#github_token)
28 | - [Create PullRequest](#create-pullrequest)
29 | - [Context variables](#context-variables)
30 | - [Context PR variables](#context-pr-variables)
31 | - [Configuration Examples](#configuration-examples)
32 | - [Example 1](#example-1)
33 | - [Example 2](#example-2)
34 | - [Example 3](#example-3)
35 | - [Author](#author)
36 |
37 |
38 |
39 | ## Installation
40 | 1. Specify location of TOC (option)
41 | e.g. `README.md`
42 | ```markdown
43 |
44 |
45 | ```
46 | [detail](https://github.com/thlorenz/doctoc#specifying-location-of-toc)
47 | 1. Setup workflow
48 | e.g. `.github/workflows/toc.yml`
49 | ```yaml
50 | on: push
51 | name: TOC Generator
52 | jobs:
53 | generateTOC:
54 | name: TOC Generator
55 | runs-on: ubuntu-latest
56 | steps:
57 | - uses: technote-space/toc-generator@v3
58 | ```
59 |
60 | ## Screenshot
61 | 
62 |
63 | ## Options
64 | | name | description | default | required | e.g. |
65 | |:---:|:---|:---:|:---:|:---:|
66 | |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`, `.`|
67 | |TOC_TITLE|TOC Title|`**Table of Contents**`| |`''`|
68 | |MAX_HEADER_LEVEL|Maximum heading level. ([Detail](https://github.com/thlorenz/doctoc#specifying-a-maximum-heading-level-for-toc-entries))| | |`3`|
69 | |CUSTOM_MODE|Whether it is custom mode([Generated Example](./__tests__/fixtures/doctoc/expected/README.horizontal2.md))|`false`| |`true`|
70 | |CUSTOM_TEMPLATE|Custom template for custom mode|`${ITEMS}
`| | |
71 | |ITEM_TEMPLATE|Item template for custom mode|`${TEXT}`| | |
72 | |SEPARATOR|Separator for custom mode|\|\| | |
73 | |FOLDING|Whether to make TOC foldable([Generated Example](./__tests__/fixtures/doctoc/expected/README.update.wrap.md))|`false`| |`true`|
74 | |COMMIT_MESSAGE|Commit message|`chore(docs): update TOC`|true|`docs: update TOC`|
75 | |COMMIT_NAME|Git commit name|`${github.actor}`| | |
76 | |COMMIT_EMAIL|Git commit email|`${github.actor}@users.noreply.github.com`| | |
77 | |CREATE_PR|Whether to check only default branch|`false`| |`true`|
78 | |CHECK_ONLY_DEFAULT_BRANCH|Whether to create PullRequest|`false`| |`true`|
79 | |PR_BRANCH_PREFIX|PullRequest branch prefix|`toc-generator/`|true| |
80 | |PR_BRANCH_NAME|PullRequest branch name
[Context variables](#context-variables)|`update-toc-${PR_ID}`|true|`toc-${PR_NUMBER}`|
81 | |PR_TITLE|PullRequest title
[Context variables](#context-variables)|`chore(docs): update TOC (${PR_MERGE_REF})`|true|`docs: update TOC`|
82 | |PR_BODY|PullRequest body
[Context PR variables](#context-pr-variables)|[action.yml](action.yml)|true| |
83 | |PR_COMMENT_BODY|PullRequest body for comment
[Context PR variables](#context-pr-variables)|[action.yml](action.yml)| | |
84 | |PR_CLOSE_MESSAGE|Message body when closing PullRequest|`This PR has been closed because it is no longer needed.`| | |
85 | |TARGET_BRANCH_PREFIX|Filter by branch name| | |`release/`|
86 | |INCLUDE_LABELS|Labels used to check if the PullRequest has it| | |`Label1, Label2`|
87 | |OPENING_COMMENT|Opening comment (for other than DocToc)|`
16 |
17 |
18 | Details
19 |
20 | - [Installation](#installation)
21 | - [Screenshot](#screenshot)
22 | - [Options](#options)
23 | - [Specify options individually](#specify-options-individually)
24 | - [Action event details](#action-event-details)
25 | - [Target event](#target-event)
26 | - [Conditions](#conditions)
27 | - [Addition](#addition)
28 | - [GITHUB_TOKEN](#github_token)
29 | - [Create PullRequest](#create-pullrequest)
30 | - [Context variables](#context-variables)
31 | - [Context PR variables](#context-pr-variables)
32 | - [Configuration Examples](#configuration-examples)
33 | - [Example 1](#example-1)
34 | - [Example 2](#example-2)
35 | - [Example 3](#example-3)
36 | - [Author](#author)
37 |
38 |
39 |
40 |
41 | ## Installation
42 | 1. Specify location of TOC (option)
43 | e.g. `README.md`
44 | ```markdown
45 |
46 |
47 | ```
48 | [detail](https://github.com/thlorenz/doctoc#specifying-location-of-toc)
49 | 1. Setup workflow
50 | e.g. `.github/workflows/toc.yml`
51 | ```yaml
52 | on: push
53 | name: TOC Generator
54 | jobs:
55 | generateTOC:
56 | name: TOC Generator
57 | runs-on: ubuntu-latest
58 | steps:
59 | - uses: technote-space/toc-generator@v4
60 | ```
61 |
62 | ## Screenshot
63 | 
64 |
65 | ## Options
66 | | name | description | default | e.g. |
67 | |:---|:---|:---|:---|
68 | |TARGET_PATHS|Target file path. (Comma separated, [Detail](https://github.com/thlorenz/doctoc#adding-toc-to-individual-files))|`README*.md`|`README*.md,CHANGELOG.md`, `.`|
69 | |TOC_TITLE|TOC Title|`**Table of Contents**`|`''`|
70 | |MAX_HEADER_LEVEL|Maximum heading level. ([Detail](https://github.com/thlorenz/doctoc#specifying-a-maximum-heading-level-for-toc-entries))| |`3`|
71 | |CUSTOM_MODE|Whether it is custom mode([Generated Example](samples/README.horizontal.md))|`false`|`true`|
72 | |CUSTOM_TEMPLATE|Custom template for custom mode|`${ITEMS}
`| |
73 | |ITEM_TEMPLATE|Item template for custom mode|`${TEXT}`| |
74 | |SEPARATOR|Separator for custom mode|\|\| |
75 | |FOLDING|Whether to make TOC foldable|`false`|`true`|
76 | |COMMIT_MESSAGE|Commit message|`chore(docs): update TOC`|`docs: update TOC`|
77 | |COMMIT_NAME|Git commit name|`${github.actor}`| |
78 | |COMMIT_EMAIL|Git commit email|`${github.actor}@users.noreply.github.com`| |
79 | |CREATE_PR|Whether to create PullRequest|`false`|`true`|
80 | |CHECK_ONLY_DEFAULT_BRANCH|Whether to check only default branch|`false`|`true`|
81 | |PR_BRANCH_PREFIX|PullRequest branch prefix|`toc-generator/`| |
82 | |PR_BRANCH_NAME|PullRequest branch name
[Context variables](#context-variables)|`update-toc-${PR_ID}`|`toc-${PR_NUMBER}`|
83 | |PR_TITLE|PullRequest title
[Context variables](#context-variables)|`chore(docs): update TOC (${PR_MERGE_REF})`|`docs: update TOC`|
84 | |PR_BODY|PullRequest body
[Context PR variables](#context-pr-variables)|[action.yml](action.yml)| |
85 | |PR_COMMENT_BODY|PullRequest body for comment
[Context PR variables](#context-pr-variables)|[action.yml](action.yml)| |
86 | |PR_CLOSE_MESSAGE|Message body when closing PullRequest|`This PR has been closed because it is no longer needed.`| |
87 | |TARGET_BRANCH_PREFIX|Filter by branch name| |`release/`|
88 | |INCLUDE_LABELS|Labels used to check if the PullRequest has it| |`Label1, Label2`|
89 | |OPENING_COMMENT|Opening comment (for other than DocToc)|`
102 |
103 |
104 |
105 |
106 |
107 | ...
108 |
109 | ```
110 |
111 | ## Action event details
112 | ### Target event
113 | | eventName: action | condition |
114 | |:---|:---|
115 | |push: *|[condition1](#condition1)|
116 | |pull_request: \[opened, synchronize, reopened, labeled, unlabeled]|[condition2](#condition2)|
117 | |pull_request: \[closed]||
118 | |schedule, repository_dispatch, workflow_dispatch||
119 |
120 | - The following activity types must be explicitly specified ([detail](https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#pull-request-event-pull_request))
121 | - `labeled`, `unlabeled`, `closed`
122 | ### Conditions
123 | #### condition1
124 | - push to branch (not tag)
125 | - branch name ([`TARGET_BRANCH_PREFIX`](#options))
126 | #### condition2
127 | - specified labels included? ([`INCLUDE_LABELS`](#options))
128 | - branch name ([`TARGET_BRANCH_PREFIX`](#options))
129 |
130 | ## Addition
131 | ### GITHUB_TOKEN
132 | The `GITHUB_TOKEN` that is provided as a part of `GitHub Actions` doesn't have authorization to create any successive events.
133 | So it won't spawn actions which triggered by push.
134 |
135 | This can be a problem if you have branch protection configured.
136 |
137 | If you want to trigger actions, use a personal access token instead.
138 | 1. Generate a [personal access token](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line) with the public_repo or repo scope.
139 | (repo is required for private repositories).
140 | 1. [Save as ACCESS_TOKEN](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets)
141 | 1. Add input to use `ACCESS_TOKEN` instead of `GITHUB_TOKEN`.
142 | e.g. `.github/workflows/toc.yml`
143 | ```yaml
144 | on: push
145 | name: TOC Generator
146 | jobs:
147 | generateTOC:
148 | name: TOC Generator
149 | runs-on: ubuntu-latest
150 | steps:
151 | - uses: technote-space/toc-generator@v4
152 | with:
153 | GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
154 | ```
155 |
156 | ### Create PullRequest
157 | If `CREATE_PR` is set to `true`, a PullRequest is created.
158 |
159 | ```yaml
160 | on: pull_request
161 | name: TOC Generator
162 | jobs:
163 | generateTOC:
164 | name: TOC Generator
165 | runs-on: ubuntu-latest
166 | steps:
167 | - uses: technote-space/toc-generator@v4
168 | with:
169 | CREATE_PR: true
170 | ```
171 |
172 | 
173 |
174 | If the `closed` activity type is set, this action closes the PR when it is no longer needed.
175 |
176 | ```yaml
177 | on:
178 | pull_request:
179 | types: [opened, synchronize, reopened, closed]
180 | name: TOC Generator
181 | jobs:
182 | generateTOC:
183 | name: TOC Generator
184 | runs-on: ubuntu-latest
185 | steps:
186 | - uses: technote-space/toc-generator@v4
187 | ```
188 |
189 | ### Context variables
190 | | name | description |
191 | |:---|:---|
192 | | PR_NUMBER | pull_request.number (e.g. `11`) |
193 | | PR_NUMBER_REF | `#${pull_request.number}` (e.g. `#11`) |
194 | | PR_ID | pull_request.id (e.g. `21031067`) |
195 | | PR_HEAD_REF | pull_request.head.ref (e.g. `change`) |
196 | | PR_BASE_REF | pull_request.base.ref (e.g. `main`) |
197 | | PR_MERGE_REF | pull_request.base.ref (e.g. `change -> main`) |
198 | | PR_TITLE | pull_request.title (e.g. `update the README with new information.`) |
199 |
200 | [Payload example](https://developer.github.com/v3/activity/events/types/#webhook-payload-example-28)
201 |
202 | ### Context PR variables
203 | - [Context variables](#context-variables)
204 |
205 | | name | description |
206 | |:---|:---|
207 | | PR_LINK | Link to PR |
208 | | COMMANDS_OUTPUT | Result of TOC command |
209 | | FILES_SUMMARY | e.g. `Changed 2 files` |
210 | | FILES | Changed file list |
211 |
212 | ## Configuration Examples
213 | ### Example 1
214 | Execute actions at push without limiting the branch and commit directly
215 |
216 | ```yaml
217 | on: push
218 | name: TOC Generator
219 | jobs:
220 | generateTOC:
221 | name: TOC Generator
222 | runs-on: ubuntu-latest
223 | steps:
224 | - uses: technote-space/toc-generator@v4
225 | ```
226 |
227 | ### Example 2
228 | Create or update a Pull Request by executing actions on a Pull Request update only for branches starting with `release/`.
229 |
230 | ```yaml
231 | on:
232 | pull_request:
233 | types: [opened, synchronize, reopened, closed]
234 | name: TOC Generator
235 | jobs:
236 | generateTOC:
237 | name: TOC Generator
238 | runs-on: ubuntu-latest
239 | steps:
240 | - uses: technote-space/toc-generator@v4
241 | with:
242 | CREATE_PR: true
243 | TARGET_BRANCH_PREFIX: release/
244 | ```
245 |
246 | ### Example 3
247 | Execute actions in the schedule for the default branch only and commit directly.
248 | (Using the Token created for the launch of other workflows)
249 |
250 | ```yaml
251 | on:
252 | schedule:
253 | - cron: "0 23 * * *"
254 | name: TOC Generator
255 | jobs:
256 | generateTOC:
257 | name: TOC Generator
258 | runs-on: ubuntu-latest
259 | steps:
260 | - uses: technote-space/toc-generator@v4
261 | with:
262 | GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
263 | CHECK_ONLY_DEFAULT_BRANCH: true
264 | ```
265 |
266 | ## Author
267 | [GitHub (Technote)](https://github.com/technote-space)
268 | [Blog](https://technote.space)
269 |
--------------------------------------------------------------------------------
/src/utils/process.test.ts:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-magic-numbers */
2 | import type { Context } from '@actions/github/lib/context';
3 | import type { MainArguments } from '@technote-space/github-action-pr-helper/dist/types';
4 | import fs from 'fs';
5 | import { resolve } from 'path';
6 | import { Logger } from '@technote-space/github-action-log-helper';
7 | import { main } from '@technote-space/github-action-pr-helper';
8 | import {
9 | generateContext,
10 | testEnv,
11 | testFs,
12 | disableNetConnect,
13 | spyOnStdout,
14 | stdoutCalledWith,
15 | spyOnSetOutput,
16 | setOutputCalledWith,
17 | getApiFixture,
18 | setChildProcessParams,
19 | testChildProcess,
20 | } from '@technote-space/github-action-test-helper';
21 | import nock from 'nock';
22 | import { beforeEach, describe, it, vi } from 'vitest';
23 | import { getRunnerArguments } from './misc';
24 |
25 | const rootDir = resolve(__dirname, '../..');
26 | const doctocDir = resolve(__dirname, '../fixtures/doctoc');
27 | const fixturesDir = resolve(__dirname, '..', 'fixtures');
28 | const title = '**test title**';
29 | const setExists = testFs();
30 | beforeEach(() => {
31 | Logger.resetForTesting();
32 | vi.spyOn(fs, 'writeFileSync').mockImplementation(() => undefined);
33 | });
34 |
35 | const context = (action: string, event = 'pull_request', ref = 'refs/pull/55/merge'): Context => generateContext({
36 | owner: 'hello',
37 | repo: 'world',
38 | event,
39 | action,
40 | ref,
41 | sha: '7638417db6d59f3c431d3e1f261cc637155684cd',
42 | }, {
43 | actor: 'test-actor',
44 | payload: {
45 | number: 11,
46 | 'pull_request': {
47 | number: 11,
48 | id: 21031067,
49 | head: {
50 | ref: 'feature/new-feature',
51 | },
52 | base: {
53 | ref: 'master',
54 | },
55 | labels: [],
56 | },
57 | },
58 | });
59 | // eslint-disable-next-line @typescript-eslint/no-explicit-any
60 | const getMainArgs = (override?: any): MainArguments => Object.assign({}, getRunnerArguments(), override ?? {});
61 |
62 | describe('main', () => {
63 | disableNetConnect(nock);
64 | testEnv(rootDir);
65 | testChildProcess();
66 |
67 | it('should do nothing if tag push', async() => {
68 | process.env.INPUT_GITHUB_TOKEN = 'test-token';
69 | const mockStdout = spyOnStdout();
70 |
71 | nock('https://api.github.com')
72 | .persist()
73 | .get('/repos/hello/world')
74 | .reply(200, () => getApiFixture(fixturesDir, 'repos.get'));
75 |
76 | await main(getMainArgs({
77 | rootDir: undefined,
78 | context: context('', 'push', 'refs/tags/v1.2.3'),
79 | }));
80 |
81 | stdoutCalledWith(mockStdout, [
82 | '> This is not a target event.',
83 | ]);
84 | });
85 |
86 | it('should do nothing if it is not a target branch', async() => {
87 | process.env.INPUT_GITHUB_TOKEN = 'test-token';
88 | process.env.INPUT_TARGET_BRANCH_PREFIX = 'prefix/';
89 | const mockStdout = spyOnStdout();
90 |
91 | nock('https://api.github.com')
92 | .persist()
93 | .get('/repos/hello/world')
94 | .reply(200, () => getApiFixture(fixturesDir, 'repos.get'));
95 |
96 | await main(getMainArgs({
97 | rootDir: undefined,
98 | context: context('opened', 'pull_request'),
99 | }));
100 |
101 | stdoutCalledWith(mockStdout, [
102 | '> This is not a target event.',
103 | ]);
104 | });
105 |
106 | it('should close pull request', async() => {
107 | process.env.GITHUB_WORKSPACE = doctocDir;
108 | process.env.INPUT_GITHUB_TOKEN = 'test-token';
109 | process.env.INPUT_PR_BRANCH_NAME = 'close/test';
110 | process.env.INPUT_TOC_TITLE = title;
111 | process.env.INPUT_CREATE_PR = 'true';
112 | const mockStdout = spyOnStdout();
113 | const mockOutput = spyOnSetOutput();
114 | setChildProcessParams({
115 | stdout: (command: string): string => {
116 | if (command.includes(' diff ')) {
117 | return '';
118 | }
119 | return 'stdout';
120 | },
121 | });
122 |
123 | nock('https://api.github.com')
124 | .persist()
125 | .get('/repos/hello/world')
126 | .reply(200, () => getApiFixture(fixturesDir, 'repos.get'))
127 | .get('/repos/hello/world/pulls?sort=created&direction=asc')
128 | .reply(200, () => getApiFixture(fixturesDir, 'pulls.list'))
129 | .get('/repos/hello/world/pulls?head=hello%3Atoc-generator%2Fclose%2Ftest')
130 | .reply(200, () => getApiFixture(fixturesDir, 'pulls.list'))
131 | .post('/repos/hello/world/issues/1347/comments')
132 | .reply(201, () => getApiFixture(fixturesDir, 'issues.comment.create'))
133 | .patch('/repos/hello/world/pulls/1347')
134 | .reply(200, () => getApiFixture(fixturesDir, 'pulls.update'))
135 | .delete('/repos/hello/world/git/refs/' + encodeURIComponent('heads/toc-generator/close/test'))
136 | .reply(204, () => getApiFixture(fixturesDir, 'pulls.update'));
137 |
138 | await main(getMainArgs({
139 | rootDir: undefined,
140 | context: context('closed'),
141 | }));
142 |
143 | stdoutCalledWith(mockStdout, [
144 | '[command]git config --global \'init.defaultBranch\' master',
145 | ' >> stdout',
146 | '::group::Target PullRequest Ref [master]',
147 | '> Fetching...',
148 | '[command]git init \'.\'',
149 | ' >> stdout',
150 | '[command]git remote add origin',
151 | ' >> stdout',
152 | '[command]git fetch --no-tags origin \'refs/heads/toc-generator/close/test:refs/remotes/origin/toc-generator/close/test\'',
153 | ' >> stdout',
154 | '[command]git reset --hard',
155 | ' >> stdout',
156 | '> Switching branch to [toc-generator/close/test]...',
157 | '[command]git checkout -b toc-generator/close/test origin/toc-generator/close/test',
158 | ' >> stdout',
159 | '[command]git checkout toc-generator/close/test',
160 | ' >> stdout',
161 | '> remote branch [toc-generator/close/test] not found.',
162 | '> now branch: ',
163 | '> Cloning [master] from the remote repo...',
164 | '[command]git init \'.\'',
165 | ' >> stdout',
166 | '[command]git remote add origin',
167 | ' >> stdout',
168 | '[command]git fetch --no-tags origin \'refs/heads/master:refs/remotes/origin/master\'',
169 | ' >> stdout',
170 | '[command]git checkout -b master origin/master',
171 | ' >> stdout',
172 | '[command]git checkout master',
173 | ' >> stdout',
174 | '[command]git checkout -b toc-generator/close/test',
175 | ' >> stdout',
176 | '[command]ls -la',
177 | ' >> stdout',
178 | '> Running commands...',
179 | '[command]DocToccing single file "[Working Directory]/README.create1.md".',
180 | '[command]DocToccing single file "[Working Directory]/README.create2.md".',
181 | '[command]DocToccing single file "[Working Directory]/README.horizontal.md".',
182 | '[command]DocToccing single file "[Working Directory]/README.not.update.md".',
183 | '[command]DocToccing single file "[Working Directory]/README.params.md".',
184 | '[command]DocToccing single file "[Working Directory]/README.skip.md".',
185 | '[command]DocToccing single file "[Working Directory]/README.toc-me.md".',
186 | '[command]DocToccing single file "[Working Directory]/README.update.md".',
187 | '[command]Run doctoc',
188 | ' >> changed:',
189 | ' >> - [Working Directory]/README.create1.md',
190 | ' >> - [Working Directory]/README.create2.md',
191 | ' >> - [Working Directory]/README.horizontal.md',
192 | ' >> - [Working Directory]/README.params.md',
193 | ' >> - [Working Directory]/README.toc-me.md',
194 | ' >> - [Working Directory]/README.update.md',
195 | ' >> unchanged:',
196 | ' >> - [Working Directory]/README.not.update.md',
197 | ' >> - [Working Directory]/README.skip.md',
198 | '> Checking diff...',
199 | '[command]git add --all',
200 | ' >> stdout',
201 | '[command]git status --short -uno',
202 | '> There is no diff.',
203 | '> Checking references diff...',
204 | '[command]git fetch --prune --no-tags --no-recurse-submodules origin +refs/heads/master:refs/remotes/origin/master',
205 | ' >> stdout',
206 | '[command]git diff \'HEAD..origin/master\' --name-only \'--diff-filter=M\'',
207 | '> Closing PullRequest... [toc-generator/close/test]',
208 | '> Deleting reference... [refs/heads/toc-generator/close/test]',
209 | '::endgroup::',
210 | '::group::Total:2 Succeeded:1 Failed:0 Skipped:1',
211 | '> \x1b[33;40m→\x1b[0m\t[octocat:new-topic] PR from fork',
212 | '> \x1b[32;40m✔\x1b[0m\t[master] has been closed because there is no reference diff',
213 | '::endgroup::',
214 | ]);
215 | setOutputCalledWith(mockOutput, [{ name: 'result', value: 'succeeded' }]);
216 | });
217 |
218 | it('should create commit', async() => {
219 | process.env.GITHUB_WORKSPACE = doctocDir;
220 | process.env.INPUT_GITHUB_TOKEN = 'test-token';
221 | process.env.INPUT_TOC_TITLE = title;
222 | const mockStdout = spyOnStdout();
223 | const mockOutput = spyOnSetOutput();
224 | setChildProcessParams({
225 | stdout: (command: string): string => {
226 | if (command.endsWith('status --short -uno')) {
227 | return 'M __tests__/fixtures/test.md';
228 | }
229 | if (command.includes(' rev-parse')) {
230 | return 'test';
231 | }
232 | return '';
233 | },
234 | });
235 | setExists(true);
236 |
237 | nock('https://api.github.com')
238 | .persist()
239 | .get('/repos/hello/world')
240 | .reply(200, () => getApiFixture(fixturesDir, 'repos.get'));
241 |
242 | await main(getMainArgs({
243 | rootDir: undefined,
244 | context: context('', 'push', 'refs/heads/test'),
245 | }));
246 |
247 | stdoutCalledWith(mockStdout, [
248 | '[command]git config --global \'init.defaultBranch\' master',
249 | '::group::Fetching...',
250 | '[command]git remote add origin',
251 | '[command]git fetch --no-tags origin \'refs/heads/test:refs/remotes/origin/test\'',
252 | '[command]git reset --hard',
253 | '::endgroup::',
254 | '::group::Switching branch to [test]...',
255 | '[command]git checkout -b test origin/test',
256 | '[command]git checkout test',
257 | '[command]git rev-parse --abbrev-ref HEAD',
258 | ' >> test',
259 | '[command]git merge --no-edit origin/test',
260 | '[command]ls -la',
261 | '::endgroup::',
262 | '::group::Running commands...',
263 | '[command]DocToccing single file "[Working Directory]/README.create1.md".',
264 | '[command]DocToccing single file "[Working Directory]/README.create2.md".',
265 | '[command]DocToccing single file "[Working Directory]/README.horizontal.md".',
266 | '[command]DocToccing single file "[Working Directory]/README.not.update.md".',
267 | '[command]DocToccing single file "[Working Directory]/README.params.md".',
268 | '[command]DocToccing single file "[Working Directory]/README.skip.md".',
269 | '[command]DocToccing single file "[Working Directory]/README.toc-me.md".',
270 | '[command]DocToccing single file "[Working Directory]/README.update.md".',
271 | '[command]Run doctoc',
272 | ' >> changed:',
273 | ' >> - [Working Directory]/README.create1.md',
274 | ' >> - [Working Directory]/README.create2.md',
275 | ' >> - [Working Directory]/README.horizontal.md',
276 | ' >> - [Working Directory]/README.params.md',
277 | ' >> - [Working Directory]/README.toc-me.md',
278 | ' >> - [Working Directory]/README.update.md',
279 | ' >> unchanged:',
280 | ' >> - [Working Directory]/README.not.update.md',
281 | ' >> - [Working Directory]/README.skip.md',
282 | '::endgroup::',
283 | '::group::Checking diff...',
284 | '[command]git add --all',
285 | '[command]git status --short -uno',
286 | '[command]git config \'user.name\' test-actor',
287 | '[command]git config \'user.email\' \'test-actor@users.noreply.github.com\'',
288 | '::endgroup::',
289 | '::group::Committing...',
290 | '[command]git commit -qm \'chore(docs): update TOC\'',
291 | '[command]git show \'--stat-count=10\' HEAD',
292 | '::endgroup::',
293 | '::group::Pushing to hello/world@test...',
294 | '[command]git push origin test:refs/heads/test',
295 | '::endgroup::',
296 | '> \x1b[32;40m✔\x1b[0m\t[feature/new-feature] updated',
297 | ]);
298 | setOutputCalledWith(mockOutput, [{ name: 'result', value: 'succeeded' }]);
299 | });
300 |
301 | it('should create pull request', async() => {
302 | process.env.GITHUB_WORKSPACE = doctocDir;
303 | process.env.INPUT_GITHUB_TOKEN = 'test-token';
304 | process.env.INPUT_TOC_TITLE = title;
305 | process.env.INPUT_TARGET_PATHS = 'README.update.md';
306 | process.env.INPUT_FOLDING = 'true';
307 | process.env.INPUT_MAX_HEADER_LEVEL = '1';
308 | process.env.INPUT_ENTRY_PREFIX = '☆';
309 | process.env.INPUT_CREATE_PR = 'true';
310 | process.env.INPUT_SIGNOFF = 'true';
311 | const mockStdout = spyOnStdout();
312 | const mockOutput = spyOnSetOutput();
313 | setChildProcessParams({
314 | stdout: (command: string): string => {
315 | if (command.endsWith('status --short -uno')) {
316 | return 'M __tests__/fixtures/test.md';
317 | }
318 | if (command.includes(' diff ')) {
319 | return '__tests__/fixtures/test.md';
320 | }
321 | if (command.includes(' rev-parse')) {
322 | return 'test';
323 | }
324 | return '';
325 | },
326 | });
327 | setExists(true);
328 |
329 | nock('https://api.github.com')
330 | .persist()
331 | .get('/repos/hello/world')
332 | .reply(200, () => getApiFixture(fixturesDir, 'repos.get'))
333 | .get('/repos/hello/world/pulls?head=hello%3Atoc-generator%2Fupdate-toc-21031067')
334 | .reply(200, () => getApiFixture(fixturesDir, 'pulls.list'))
335 | .get('/repos/hello/world/pulls?head=hello%3Atest')
336 | .reply(200, () => getApiFixture(fixturesDir, 'pulls.list'))
337 | .post('/repos/hello/world/issues/1347/comments')
338 | .reply(201)
339 | .get('/repos/hello/world/pulls/1347')
340 | .reply(200, () => getApiFixture(fixturesDir, 'pulls.get'));
341 |
342 | await main(getMainArgs({
343 | rootDir: undefined,
344 | context: context('synchronize'),
345 | }));
346 |
347 | stdoutCalledWith(mockStdout, [
348 | '[command]git config --global \'init.defaultBranch\' master',
349 | '::group::Fetching...',
350 | '[command]git remote add origin',
351 | '[command]git fetch --no-tags origin \'refs/heads/toc-generator/update-toc-21031067:refs/remotes/origin/toc-generator/update-toc-21031067\'',
352 | '[command]git reset --hard',
353 | '::endgroup::',
354 | '::group::Switching branch to [toc-generator/update-toc-21031067]...',
355 | '[command]git checkout -b toc-generator/update-toc-21031067 origin/toc-generator/update-toc-21031067',
356 | '[command]git checkout toc-generator/update-toc-21031067',
357 | '[command]git rev-parse --abbrev-ref HEAD',
358 | ' >> test',
359 | '> remote branch [toc-generator/update-toc-21031067] not found.',
360 | '> now branch: test',
361 | '::endgroup::',
362 | '::group::Cloning [feature/new-feature] from the remote repo...',
363 | '[command]git remote add origin',
364 | '[command]git fetch --no-tags origin \'refs/heads/feature/new-feature:refs/remotes/origin/feature/new-feature\'',
365 | '[command]git checkout -b feature/new-feature origin/feature/new-feature',
366 | '[command]git checkout feature/new-feature',
367 | '[command]git checkout -b toc-generator/update-toc-21031067',
368 | '[command]ls -la',
369 | '::endgroup::',
370 | '::group::Running commands...',
371 | '[command]DocToccing single file "[Working Directory]/README.update.md".',
372 | '[command]Run doctoc',
373 | ' >> changed:',
374 | ' >> - [Working Directory]/README.update.md',
375 | ' >> unchanged:',
376 | '::endgroup::',
377 | '::group::Checking diff...',
378 | '[command]git add --all',
379 | '[command]git status --short -uno',
380 | '[command]git config \'user.name\' test-actor',
381 | '[command]git config \'user.email\' \'test-actor@users.noreply.github.com\'',
382 | '::endgroup::',
383 | '::group::Committing...',
384 | '[command]git commit --signoff -qm \'chore(docs): update TOC\'',
385 | '[command]git show \'--stat-count=10\' HEAD',
386 | '::endgroup::',
387 | '::group::Checking references diff...',
388 | '[command]git fetch --prune --no-tags --no-recurse-submodules origin +refs/heads/feature/new-feature:refs/remotes/origin/feature/new-feature',
389 | '[command]git diff \'HEAD..origin/feature/new-feature\' --name-only \'--diff-filter=M\'',
390 | '::endgroup::',
391 | '::group::Pushing to hello/world@toc-generator/update-toc-21031067...',
392 | '[command]git push origin toc-generator/update-toc-21031067:refs/heads/toc-generator/update-toc-21031067',
393 | '::endgroup::',
394 | '::group::Creating comment to PullRequest...',
395 | '::endgroup::',
396 | '> \x1b[32;40m✔\x1b[0m\t[feature/new-feature] updated',
397 | ]);
398 | setOutputCalledWith(mockOutput, [{ name: 'result', value: 'succeeded' }]);
399 | });
400 | });
401 |
--------------------------------------------------------------------------------
/src/fixtures/repos.get.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": 1296269,
3 | "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
4 | "name": "Hello-World",
5 | "full_name": "octocat/Hello-World",
6 | "owner": {
7 | "login": "octocat",
8 | "id": 1,
9 | "node_id": "MDQ6VXNlcjE=",
10 | "avatar_url": "https://github.com/images/error/octocat_happy.gif",
11 | "gravatar_id": "",
12 | "url": "https://api.github.com/users/octocat",
13 | "html_url": "https://github.com/octocat",
14 | "followers_url": "https://api.github.com/users/octocat/followers",
15 | "following_url": "https://api.github.com/users/octocat/following{/other_user}",
16 | "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
17 | "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
18 | "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
19 | "organizations_url": "https://api.github.com/users/octocat/orgs",
20 | "repos_url": "https://api.github.com/users/octocat/repos",
21 | "events_url": "https://api.github.com/users/octocat/events{/privacy}",
22 | "received_events_url": "https://api.github.com/users/octocat/received_events",
23 | "type": "User",
24 | "site_admin": false
25 | },
26 | "private": false,
27 | "html_url": "https://github.com/octocat/Hello-World",
28 | "description": "This your first repo!",
29 | "fork": false,
30 | "url": "https://api.github.com/repos/octocat/Hello-World",
31 | "archive_url": "http://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}",
32 | "assignees_url": "http://api.github.com/repos/octocat/Hello-World/assignees{/user}",
33 | "blobs_url": "http://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}",
34 | "branches_url": "http://api.github.com/repos/octocat/Hello-World/branches{/branch}",
35 | "collaborators_url": "http://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}",
36 | "comments_url": "http://api.github.com/repos/octocat/Hello-World/comments{/number}",
37 | "commits_url": "http://api.github.com/repos/octocat/Hello-World/commits{/sha}",
38 | "compare_url": "http://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}",
39 | "contents_url": "http://api.github.com/repos/octocat/Hello-World/contents/{+path}",
40 | "contributors_url": "http://api.github.com/repos/octocat/Hello-World/contributors",
41 | "deployments_url": "http://api.github.com/repos/octocat/Hello-World/deployments",
42 | "downloads_url": "http://api.github.com/repos/octocat/Hello-World/downloads",
43 | "events_url": "http://api.github.com/repos/octocat/Hello-World/events",
44 | "forks_url": "http://api.github.com/repos/octocat/Hello-World/forks",
45 | "git_commits_url": "http://api.github.com/repos/octocat/Hello-World/git/commits{/sha}",
46 | "git_refs_url": "http://api.github.com/repos/octocat/Hello-World/git/refs{/sha}",
47 | "git_tags_url": "http://api.github.com/repos/octocat/Hello-World/git/tags{/sha}",
48 | "git_url": "git:github.com/octocat/Hello-World.git",
49 | "issue_comment_url": "http://api.github.com/repos/octocat/Hello-World/issues/comments{/number}",
50 | "issue_events_url": "http://api.github.com/repos/octocat/Hello-World/issues/events{/number}",
51 | "issues_url": "http://api.github.com/repos/octocat/Hello-World/issues{/number}",
52 | "keys_url": "http://api.github.com/repos/octocat/Hello-World/keys{/key_id}",
53 | "labels_url": "http://api.github.com/repos/octocat/Hello-World/labels{/name}",
54 | "languages_url": "http://api.github.com/repos/octocat/Hello-World/languages",
55 | "merges_url": "http://api.github.com/repos/octocat/Hello-World/merges",
56 | "milestones_url": "http://api.github.com/repos/octocat/Hello-World/milestones{/number}",
57 | "notifications_url": "http://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}",
58 | "pulls_url": "http://api.github.com/repos/octocat/Hello-World/pulls{/number}",
59 | "releases_url": "http://api.github.com/repos/octocat/Hello-World/releases{/id}",
60 | "ssh_url": "git@github.com:octocat/Hello-World.git",
61 | "stargazers_url": "http://api.github.com/repos/octocat/Hello-World/stargazers",
62 | "statuses_url": "http://api.github.com/repos/octocat/Hello-World/statuses/{sha}",
63 | "subscribers_url": "http://api.github.com/repos/octocat/Hello-World/subscribers",
64 | "subscription_url": "http://api.github.com/repos/octocat/Hello-World/subscription",
65 | "tags_url": "http://api.github.com/repos/octocat/Hello-World/tags",
66 | "teams_url": "http://api.github.com/repos/octocat/Hello-World/teams",
67 | "trees_url": "http://api.github.com/repos/octocat/Hello-World/git/trees{/sha}",
68 | "clone_url": "https://github.com/octocat/Hello-World.git",
69 | "mirror_url": "git:git.example.com/octocat/Hello-World",
70 | "hooks_url": "http://api.github.com/repos/octocat/Hello-World/hooks",
71 | "svn_url": "https://svn.github.com/octocat/Hello-World",
72 | "homepage": "https://github.com",
73 | "language": null,
74 | "forks_count": 9,
75 | "stargazers_count": 80,
76 | "watchers_count": 80,
77 | "size": 108,
78 | "default_branch": "master",
79 | "open_issues_count": 0,
80 | "is_template": true,
81 | "topics": [
82 | "octocat",
83 | "atom",
84 | "electron",
85 | "api"
86 | ],
87 | "has_issues": true,
88 | "has_projects": true,
89 | "has_wiki": true,
90 | "has_pages": false,
91 | "has_downloads": true,
92 | "archived": false,
93 | "disabled": false,
94 | "pushed_at": "2011-01-26T19:06:43Z",
95 | "created_at": "2011-01-26T19:01:12Z",
96 | "updated_at": "2011-01-26T19:14:43Z",
97 | "permissions": {
98 | "admin": false,
99 | "push": false,
100 | "pull": true
101 | },
102 | "allow_rebase_merge": true,
103 | "template_repository": null,
104 | "allow_squash_merge": true,
105 | "allow_merge_commit": true,
106 | "subscribers_count": 42,
107 | "network_count": 0,
108 | "license": {
109 | "key": "mit",
110 | "name": "MIT License",
111 | "spdx_id": "MIT",
112 | "url": "https://api.github.com/licenses/mit",
113 | "node_id": "MDc6TGljZW5zZW1pdA=="
114 | },
115 | "organization": {
116 | "login": "octocat",
117 | "id": 1,
118 | "node_id": "MDQ6VXNlcjE=",
119 | "avatar_url": "https://github.com/images/error/octocat_happy.gif",
120 | "gravatar_id": "",
121 | "url": "https://api.github.com/users/octocat",
122 | "html_url": "https://github.com/octocat",
123 | "followers_url": "https://api.github.com/users/octocat/followers",
124 | "following_url": "https://api.github.com/users/octocat/following{/other_user}",
125 | "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
126 | "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
127 | "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
128 | "organizations_url": "https://api.github.com/users/octocat/orgs",
129 | "repos_url": "https://api.github.com/users/octocat/repos",
130 | "events_url": "https://api.github.com/users/octocat/events{/privacy}",
131 | "received_events_url": "https://api.github.com/users/octocat/received_events",
132 | "type": "Organization",
133 | "site_admin": false
134 | },
135 | "parent": {
136 | "id": 1296269,
137 | "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
138 | "name": "Hello-World",
139 | "full_name": "octocat/Hello-World",
140 | "owner": {
141 | "login": "octocat",
142 | "id": 1,
143 | "node_id": "MDQ6VXNlcjE=",
144 | "avatar_url": "https://github.com/images/error/octocat_happy.gif",
145 | "gravatar_id": "",
146 | "url": "https://api.github.com/users/octocat",
147 | "html_url": "https://github.com/octocat",
148 | "followers_url": "https://api.github.com/users/octocat/followers",
149 | "following_url": "https://api.github.com/users/octocat/following{/other_user}",
150 | "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
151 | "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
152 | "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
153 | "organizations_url": "https://api.github.com/users/octocat/orgs",
154 | "repos_url": "https://api.github.com/users/octocat/repos",
155 | "events_url": "https://api.github.com/users/octocat/events{/privacy}",
156 | "received_events_url": "https://api.github.com/users/octocat/received_events",
157 | "type": "User",
158 | "site_admin": false
159 | },
160 | "private": false,
161 | "html_url": "https://github.com/octocat/Hello-World",
162 | "description": "This your first repo!",
163 | "fork": false,
164 | "url": "https://api.github.com/repos/octocat/Hello-World",
165 | "archive_url": "http://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}",
166 | "assignees_url": "http://api.github.com/repos/octocat/Hello-World/assignees{/user}",
167 | "blobs_url": "http://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}",
168 | "branches_url": "http://api.github.com/repos/octocat/Hello-World/branches{/branch}",
169 | "collaborators_url": "http://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}",
170 | "comments_url": "http://api.github.com/repos/octocat/Hello-World/comments{/number}",
171 | "commits_url": "http://api.github.com/repos/octocat/Hello-World/commits{/sha}",
172 | "compare_url": "http://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}",
173 | "contents_url": "http://api.github.com/repos/octocat/Hello-World/contents/{+path}",
174 | "contributors_url": "http://api.github.com/repos/octocat/Hello-World/contributors",
175 | "deployments_url": "http://api.github.com/repos/octocat/Hello-World/deployments",
176 | "downloads_url": "http://api.github.com/repos/octocat/Hello-World/downloads",
177 | "events_url": "http://api.github.com/repos/octocat/Hello-World/events",
178 | "forks_url": "http://api.github.com/repos/octocat/Hello-World/forks",
179 | "git_commits_url": "http://api.github.com/repos/octocat/Hello-World/git/commits{/sha}",
180 | "git_refs_url": "http://api.github.com/repos/octocat/Hello-World/git/refs{/sha}",
181 | "git_tags_url": "http://api.github.com/repos/octocat/Hello-World/git/tags{/sha}",
182 | "git_url": "git:github.com/octocat/Hello-World.git",
183 | "issue_comment_url": "http://api.github.com/repos/octocat/Hello-World/issues/comments{/number}",
184 | "issue_events_url": "http://api.github.com/repos/octocat/Hello-World/issues/events{/number}",
185 | "issues_url": "http://api.github.com/repos/octocat/Hello-World/issues{/number}",
186 | "keys_url": "http://api.github.com/repos/octocat/Hello-World/keys{/key_id}",
187 | "labels_url": "http://api.github.com/repos/octocat/Hello-World/labels{/name}",
188 | "languages_url": "http://api.github.com/repos/octocat/Hello-World/languages",
189 | "merges_url": "http://api.github.com/repos/octocat/Hello-World/merges",
190 | "milestones_url": "http://api.github.com/repos/octocat/Hello-World/milestones{/number}",
191 | "notifications_url": "http://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}",
192 | "pulls_url": "http://api.github.com/repos/octocat/Hello-World/pulls{/number}",
193 | "releases_url": "http://api.github.com/repos/octocat/Hello-World/releases{/id}",
194 | "ssh_url": "git@github.com:octocat/Hello-World.git",
195 | "stargazers_url": "http://api.github.com/repos/octocat/Hello-World/stargazers",
196 | "statuses_url": "http://api.github.com/repos/octocat/Hello-World/statuses/{sha}",
197 | "subscribers_url": "http://api.github.com/repos/octocat/Hello-World/subscribers",
198 | "subscription_url": "http://api.github.com/repos/octocat/Hello-World/subscription",
199 | "tags_url": "http://api.github.com/repos/octocat/Hello-World/tags",
200 | "teams_url": "http://api.github.com/repos/octocat/Hello-World/teams",
201 | "trees_url": "http://api.github.com/repos/octocat/Hello-World/git/trees{/sha}",
202 | "clone_url": "https://github.com/octocat/Hello-World.git",
203 | "mirror_url": "git:git.example.com/octocat/Hello-World",
204 | "hooks_url": "http://api.github.com/repos/octocat/Hello-World/hooks",
205 | "svn_url": "https://svn.github.com/octocat/Hello-World",
206 | "homepage": "https://github.com",
207 | "language": null,
208 | "forks_count": 9,
209 | "stargazers_count": 80,
210 | "watchers_count": 80,
211 | "size": 108,
212 | "default_branch": "master",
213 | "open_issues_count": 0,
214 | "is_template": true,
215 | "topics": [
216 | "octocat",
217 | "atom",
218 | "electron",
219 | "api"
220 | ],
221 | "has_issues": true,
222 | "has_projects": true,
223 | "has_wiki": true,
224 | "has_pages": false,
225 | "has_downloads": true,
226 | "archived": false,
227 | "disabled": false,
228 | "pushed_at": "2011-01-26T19:06:43Z",
229 | "created_at": "2011-01-26T19:01:12Z",
230 | "updated_at": "2011-01-26T19:14:43Z",
231 | "permissions": {
232 | "admin": false,
233 | "push": false,
234 | "pull": true
235 | },
236 | "allow_rebase_merge": true,
237 | "template_repository": null,
238 | "allow_squash_merge": true,
239 | "allow_merge_commit": true,
240 | "subscribers_count": 42,
241 | "network_count": 0
242 | },
243 | "source": {
244 | "id": 1296269,
245 | "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
246 | "name": "Hello-World",
247 | "full_name": "octocat/Hello-World",
248 | "owner": {
249 | "login": "octocat",
250 | "id": 1,
251 | "node_id": "MDQ6VXNlcjE=",
252 | "avatar_url": "https://github.com/images/error/octocat_happy.gif",
253 | "gravatar_id": "",
254 | "url": "https://api.github.com/users/octocat",
255 | "html_url": "https://github.com/octocat",
256 | "followers_url": "https://api.github.com/users/octocat/followers",
257 | "following_url": "https://api.github.com/users/octocat/following{/other_user}",
258 | "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
259 | "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
260 | "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
261 | "organizations_url": "https://api.github.com/users/octocat/orgs",
262 | "repos_url": "https://api.github.com/users/octocat/repos",
263 | "events_url": "https://api.github.com/users/octocat/events{/privacy}",
264 | "received_events_url": "https://api.github.com/users/octocat/received_events",
265 | "type": "User",
266 | "site_admin": false
267 | },
268 | "private": false,
269 | "html_url": "https://github.com/octocat/Hello-World",
270 | "description": "This your first repo!",
271 | "fork": false,
272 | "url": "https://api.github.com/repos/octocat/Hello-World",
273 | "archive_url": "http://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}",
274 | "assignees_url": "http://api.github.com/repos/octocat/Hello-World/assignees{/user}",
275 | "blobs_url": "http://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}",
276 | "branches_url": "http://api.github.com/repos/octocat/Hello-World/branches{/branch}",
277 | "collaborators_url": "http://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}",
278 | "comments_url": "http://api.github.com/repos/octocat/Hello-World/comments{/number}",
279 | "commits_url": "http://api.github.com/repos/octocat/Hello-World/commits{/sha}",
280 | "compare_url": "http://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}",
281 | "contents_url": "http://api.github.com/repos/octocat/Hello-World/contents/{+path}",
282 | "contributors_url": "http://api.github.com/repos/octocat/Hello-World/contributors",
283 | "deployments_url": "http://api.github.com/repos/octocat/Hello-World/deployments",
284 | "downloads_url": "http://api.github.com/repos/octocat/Hello-World/downloads",
285 | "events_url": "http://api.github.com/repos/octocat/Hello-World/events",
286 | "forks_url": "http://api.github.com/repos/octocat/Hello-World/forks",
287 | "git_commits_url": "http://api.github.com/repos/octocat/Hello-World/git/commits{/sha}",
288 | "git_refs_url": "http://api.github.com/repos/octocat/Hello-World/git/refs{/sha}",
289 | "git_tags_url": "http://api.github.com/repos/octocat/Hello-World/git/tags{/sha}",
290 | "git_url": "git:github.com/octocat/Hello-World.git",
291 | "issue_comment_url": "http://api.github.com/repos/octocat/Hello-World/issues/comments{/number}",
292 | "issue_events_url": "http://api.github.com/repos/octocat/Hello-World/issues/events{/number}",
293 | "issues_url": "http://api.github.com/repos/octocat/Hello-World/issues{/number}",
294 | "keys_url": "http://api.github.com/repos/octocat/Hello-World/keys{/key_id}",
295 | "labels_url": "http://api.github.com/repos/octocat/Hello-World/labels{/name}",
296 | "languages_url": "http://api.github.com/repos/octocat/Hello-World/languages",
297 | "merges_url": "http://api.github.com/repos/octocat/Hello-World/merges",
298 | "milestones_url": "http://api.github.com/repos/octocat/Hello-World/milestones{/number}",
299 | "notifications_url": "http://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}",
300 | "pulls_url": "http://api.github.com/repos/octocat/Hello-World/pulls{/number}",
301 | "releases_url": "http://api.github.com/repos/octocat/Hello-World/releases{/id}",
302 | "ssh_url": "git@github.com:octocat/Hello-World.git",
303 | "stargazers_url": "http://api.github.com/repos/octocat/Hello-World/stargazers",
304 | "statuses_url": "http://api.github.com/repos/octocat/Hello-World/statuses/{sha}",
305 | "subscribers_url": "http://api.github.com/repos/octocat/Hello-World/subscribers",
306 | "subscription_url": "http://api.github.com/repos/octocat/Hello-World/subscription",
307 | "tags_url": "http://api.github.com/repos/octocat/Hello-World/tags",
308 | "teams_url": "http://api.github.com/repos/octocat/Hello-World/teams",
309 | "trees_url": "http://api.github.com/repos/octocat/Hello-World/git/trees{/sha}",
310 | "clone_url": "https://github.com/octocat/Hello-World.git",
311 | "mirror_url": "git:git.example.com/octocat/Hello-World",
312 | "hooks_url": "http://api.github.com/repos/octocat/Hello-World/hooks",
313 | "svn_url": "https://svn.github.com/octocat/Hello-World",
314 | "homepage": "https://github.com",
315 | "language": null,
316 | "forks_count": 9,
317 | "stargazers_count": 80,
318 | "watchers_count": 80,
319 | "size": 108,
320 | "default_branch": "master",
321 | "open_issues_count": 0,
322 | "is_template": true,
323 | "topics": [
324 | "octocat",
325 | "atom",
326 | "electron",
327 | "api"
328 | ],
329 | "has_issues": true,
330 | "has_projects": true,
331 | "has_wiki": true,
332 | "has_pages": false,
333 | "has_downloads": true,
334 | "archived": false,
335 | "disabled": false,
336 | "pushed_at": "2011-01-26T19:06:43Z",
337 | "created_at": "2011-01-26T19:01:12Z",
338 | "updated_at": "2011-01-26T19:14:43Z",
339 | "permissions": {
340 | "admin": false,
341 | "push": false,
342 | "pull": true
343 | },
344 | "allow_rebase_merge": true,
345 | "template_repository": null,
346 | "allow_squash_merge": true,
347 | "allow_merge_commit": true,
348 | "subscribers_count": 42,
349 | "network_count": 0
350 | }
351 | }
--------------------------------------------------------------------------------
/src/fixtures/pulls.update.json:
--------------------------------------------------------------------------------
1 | {
2 | "url": "https://api.github.com/repos/hello/world/pulls/1347",
3 | "id": 1,
4 | "node_id": "MDExOlB1bGxSZXF1ZXN0MQ==",
5 | "html_url": "https://github.com/hello/world/pull/1347",
6 | "diff_url": "https://github.com/hello/world/pull/1347.diff",
7 | "patch_url": "https://github.com/hello/world/pull/1347.patch",
8 | "issue_url": "https://api.github.com/repos/hello/world/issues/1347",
9 | "commits_url": "https://api.github.com/repos/hello/world/pulls/1347/commits",
10 | "review_comments_url": "https://api.github.com/repos/hello/world/pulls/1347/comments",
11 | "review_comment_url": "https://api.github.com/repos/hello/world/pulls/comments{/number}",
12 | "comments_url": "https://api.github.com/repos/hello/world/issues/1347/comments",
13 | "statuses_url": "https://api.github.com/repos/hello/world/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e",
14 | "number": 1347,
15 | "state": "open",
16 | "locked": true,
17 | "title": "Amazing new feature",
18 | "user": {
19 | "login": "octocat",
20 | "id": 1,
21 | "node_id": "MDQ6VXNlcjE=",
22 | "avatar_url": "https://github.com/images/error/octocat_happy.gif",
23 | "gravatar_id": "",
24 | "url": "https://api.github.com/users/octocat",
25 | "html_url": "https://github.com/octocat",
26 | "followers_url": "https://api.github.com/users/octocat/followers",
27 | "following_url": "https://api.github.com/users/octocat/following{/other_user}",
28 | "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
29 | "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
30 | "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
31 | "organizations_url": "https://api.github.com/users/octocat/orgs",
32 | "repos_url": "https://api.github.com/users/octocat/repos",
33 | "events_url": "https://api.github.com/users/octocat/events{/privacy}",
34 | "received_events_url": "https://api.github.com/users/octocat/received_events",
35 | "type": "User",
36 | "site_admin": false
37 | },
38 | "body": "Please pull these awesome changes in!",
39 | "labels": [
40 | {
41 | "id": 208045946,
42 | "node_id": "MDU6TGFiZWwyMDgwNDU5NDY=",
43 | "url": "https://api.github.com/repos/hello/world/labels/bug",
44 | "name": "bug",
45 | "description": "Something isn't working",
46 | "color": "f29513",
47 | "default": true
48 | }
49 | ],
50 | "milestone": {
51 | "url": "https://api.github.com/repos/hello/world/milestones/1",
52 | "html_url": "https://github.com/hello/world/milestones/v1.0",
53 | "labels_url": "https://api.github.com/repos/hello/world/milestones/1/labels",
54 | "id": 1002604,
55 | "node_id": "MDk6TWlsZXN0b25lMTAwMjYwNA==",
56 | "number": 1,
57 | "state": "open",
58 | "title": "v1.0",
59 | "description": "Tracking milestone for version 1.0",
60 | "creator": {
61 | "login": "octocat",
62 | "id": 1,
63 | "node_id": "MDQ6VXNlcjE=",
64 | "avatar_url": "https://github.com/images/error/octocat_happy.gif",
65 | "gravatar_id": "",
66 | "url": "https://api.github.com/users/octocat",
67 | "html_url": "https://github.com/octocat",
68 | "followers_url": "https://api.github.com/users/octocat/followers",
69 | "following_url": "https://api.github.com/users/octocat/following{/other_user}",
70 | "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
71 | "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
72 | "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
73 | "organizations_url": "https://api.github.com/users/octocat/orgs",
74 | "repos_url": "https://api.github.com/users/octocat/repos",
75 | "events_url": "https://api.github.com/users/octocat/events{/privacy}",
76 | "received_events_url": "https://api.github.com/users/octocat/received_events",
77 | "type": "User",
78 | "site_admin": false
79 | },
80 | "open_issues": 4,
81 | "closed_issues": 8,
82 | "created_at": "2011-04-10T20:09:31Z",
83 | "updated_at": "2014-03-03T18:58:10Z",
84 | "closed_at": "2013-02-12T13:22:01Z",
85 | "due_on": "2012-10-09T23:39:01Z"
86 | },
87 | "active_lock_reason": "too heated",
88 | "created_at": "2011-01-26T19:01:12Z",
89 | "updated_at": "2011-01-26T19:01:12Z",
90 | "closed_at": "2011-01-26T19:01:12Z",
91 | "merged_at": "2011-01-26T19:01:12Z",
92 | "merge_commit_sha": "e5bd3914e2e596debea16f433f57875b5b90bcd6",
93 | "assignee": {
94 | "login": "octocat",
95 | "id": 1,
96 | "node_id": "MDQ6VXNlcjE=",
97 | "avatar_url": "https://github.com/images/error/octocat_happy.gif",
98 | "gravatar_id": "",
99 | "url": "https://api.github.com/users/octocat",
100 | "html_url": "https://github.com/octocat",
101 | "followers_url": "https://api.github.com/users/octocat/followers",
102 | "following_url": "https://api.github.com/users/octocat/following{/other_user}",
103 | "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
104 | "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
105 | "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
106 | "organizations_url": "https://api.github.com/users/octocat/orgs",
107 | "repos_url": "https://api.github.com/users/octocat/repos",
108 | "events_url": "https://api.github.com/users/octocat/events{/privacy}",
109 | "received_events_url": "https://api.github.com/users/octocat/received_events",
110 | "type": "User",
111 | "site_admin": false
112 | },
113 | "assignees": [
114 | {
115 | "login": "octocat",
116 | "id": 1,
117 | "node_id": "MDQ6VXNlcjE=",
118 | "avatar_url": "https://github.com/images/error/octocat_happy.gif",
119 | "gravatar_id": "",
120 | "url": "https://api.github.com/users/octocat",
121 | "html_url": "https://github.com/octocat",
122 | "followers_url": "https://api.github.com/users/octocat/followers",
123 | "following_url": "https://api.github.com/users/octocat/following{/other_user}",
124 | "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
125 | "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
126 | "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
127 | "organizations_url": "https://api.github.com/users/octocat/orgs",
128 | "repos_url": "https://api.github.com/users/octocat/repos",
129 | "events_url": "https://api.github.com/users/octocat/events{/privacy}",
130 | "received_events_url": "https://api.github.com/users/octocat/received_events",
131 | "type": "User",
132 | "site_admin": false
133 | },
134 | {
135 | "login": "hubot",
136 | "id": 1,
137 | "node_id": "MDQ6VXNlcjE=",
138 | "avatar_url": "https://github.com/images/error/hubot_happy.gif",
139 | "gravatar_id": "",
140 | "url": "https://api.github.com/users/hubot",
141 | "html_url": "https://github.com/hubot",
142 | "followers_url": "https://api.github.com/users/hubot/followers",
143 | "following_url": "https://api.github.com/users/hubot/following{/other_user}",
144 | "gists_url": "https://api.github.com/users/hubot/gists{/gist_id}",
145 | "starred_url": "https://api.github.com/users/hubot/starred{/owner}{/repo}",
146 | "subscriptions_url": "https://api.github.com/users/hubot/subscriptions",
147 | "organizations_url": "https://api.github.com/users/hubot/orgs",
148 | "repos_url": "https://api.github.com/users/hubot/repos",
149 | "events_url": "https://api.github.com/users/hubot/events{/privacy}",
150 | "received_events_url": "https://api.github.com/users/hubot/received_events",
151 | "type": "User",
152 | "site_admin": true
153 | }
154 | ],
155 | "requested_reviewers": [
156 | {
157 | "login": "other_user",
158 | "id": 1,
159 | "node_id": "MDQ6VXNlcjE=",
160 | "avatar_url": "https://github.com/images/error/other_user_happy.gif",
161 | "gravatar_id": "",
162 | "url": "https://api.github.com/users/other_user",
163 | "html_url": "https://github.com/other_user",
164 | "followers_url": "https://api.github.com/users/other_user/followers",
165 | "following_url": "https://api.github.com/users/other_user/following{/other_user}",
166 | "gists_url": "https://api.github.com/users/other_user/gists{/gist_id}",
167 | "starred_url": "https://api.github.com/users/other_user/starred{/owner}{/repo}",
168 | "subscriptions_url": "https://api.github.com/users/other_user/subscriptions",
169 | "organizations_url": "https://api.github.com/users/other_user/orgs",
170 | "repos_url": "https://api.github.com/users/other_user/repos",
171 | "events_url": "https://api.github.com/users/other_user/events{/privacy}",
172 | "received_events_url": "https://api.github.com/users/other_user/received_events",
173 | "type": "User",
174 | "site_admin": false
175 | }
176 | ],
177 | "requested_teams": [
178 | {
179 | "id": 1,
180 | "node_id": "MDQ6VGVhbTE=",
181 | "url": "https://api.github.com/teams/1",
182 | "html_url": "https://api.github.com/teams/justice-league",
183 | "name": "Justice League",
184 | "slug": "justice-league",
185 | "description": "A great team.",
186 | "privacy": "closed",
187 | "permission": "admin",
188 | "members_url": "https://api.github.com/teams/1/members{/member}",
189 | "repositories_url": "https://api.github.com/teams/1/repos",
190 | "parent": null
191 | }
192 | ],
193 | "head": {
194 | "label": "octocat:new-topic",
195 | "ref": "new-topic",
196 | "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
197 | "user": {
198 | "login": "octocat",
199 | "id": 1,
200 | "node_id": "MDQ6VXNlcjE=",
201 | "avatar_url": "https://github.com/images/error/octocat_happy.gif",
202 | "gravatar_id": "",
203 | "url": "https://api.github.com/users/octocat",
204 | "html_url": "https://github.com/octocat",
205 | "followers_url": "https://api.github.com/users/octocat/followers",
206 | "following_url": "https://api.github.com/users/octocat/following{/other_user}",
207 | "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
208 | "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
209 | "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
210 | "organizations_url": "https://api.github.com/users/octocat/orgs",
211 | "repos_url": "https://api.github.com/users/octocat/repos",
212 | "events_url": "https://api.github.com/users/octocat/events{/privacy}",
213 | "received_events_url": "https://api.github.com/users/octocat/received_events",
214 | "type": "User",
215 | "site_admin": false
216 | },
217 | "repo": {
218 | "id": 1296269,
219 | "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
220 | "name": "Hello-World",
221 | "full_name": "hello/world",
222 | "owner": {
223 | "login": "octocat",
224 | "id": 1,
225 | "node_id": "MDQ6VXNlcjE=",
226 | "avatar_url": "https://github.com/images/error/octocat_happy.gif",
227 | "gravatar_id": "",
228 | "url": "https://api.github.com/users/octocat",
229 | "html_url": "https://github.com/octocat",
230 | "followers_url": "https://api.github.com/users/octocat/followers",
231 | "following_url": "https://api.github.com/users/octocat/following{/other_user}",
232 | "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
233 | "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
234 | "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
235 | "organizations_url": "https://api.github.com/users/octocat/orgs",
236 | "repos_url": "https://api.github.com/users/octocat/repos",
237 | "events_url": "https://api.github.com/users/octocat/events{/privacy}",
238 | "received_events_url": "https://api.github.com/users/octocat/received_events",
239 | "type": "User",
240 | "site_admin": false
241 | },
242 | "private": false,
243 | "html_url": "https://github.com/hello/world",
244 | "description": "This your first repo!",
245 | "fork": false,
246 | "url": "https://api.github.com/repos/hello/world",
247 | "archive_url": "http://api.github.com/repos/hello/world/{archive_format}{/ref}",
248 | "assignees_url": "http://api.github.com/repos/hello/world/assignees{/user}",
249 | "blobs_url": "http://api.github.com/repos/hello/world/git/blobs{/sha}",
250 | "branches_url": "http://api.github.com/repos/hello/world/branches{/branch}",
251 | "collaborators_url": "http://api.github.com/repos/hello/world/collaborators{/collaborator}",
252 | "comments_url": "http://api.github.com/repos/hello/world/comments{/number}",
253 | "commits_url": "http://api.github.com/repos/hello/world/commits{/sha}",
254 | "compare_url": "http://api.github.com/repos/hello/world/compare/{base}...{head}",
255 | "contents_url": "http://api.github.com/repos/hello/world/contents/{+path}",
256 | "contributors_url": "http://api.github.com/repos/hello/world/contributors",
257 | "deployments_url": "http://api.github.com/repos/hello/world/deployments",
258 | "downloads_url": "http://api.github.com/repos/hello/world/downloads",
259 | "events_url": "http://api.github.com/repos/hello/world/events",
260 | "forks_url": "http://api.github.com/repos/hello/world/forks",
261 | "git_commits_url": "http://api.github.com/repos/hello/world/git/commits{/sha}",
262 | "git_refs_url": "http://api.github.com/repos/hello/world/git/refs{/sha}",
263 | "git_tags_url": "http://api.github.com/repos/hello/world/git/tags{/sha}",
264 | "git_url": "git:github.com/hello/world.git",
265 | "issue_comment_url": "http://api.github.com/repos/hello/world/issues/comments{/number}",
266 | "issue_events_url": "http://api.github.com/repos/hello/world/issues/events{/number}",
267 | "issues_url": "http://api.github.com/repos/hello/world/issues{/number}",
268 | "keys_url": "http://api.github.com/repos/hello/world/keys{/key_id}",
269 | "labels_url": "http://api.github.com/repos/hello/world/labels{/name}",
270 | "languages_url": "http://api.github.com/repos/hello/world/languages",
271 | "merges_url": "http://api.github.com/repos/hello/world/merges",
272 | "milestones_url": "http://api.github.com/repos/hello/world/milestones{/number}",
273 | "notifications_url": "http://api.github.com/repos/hello/world/notifications{?since,all,participating}",
274 | "pulls_url": "http://api.github.com/repos/hello/world/pulls{/number}",
275 | "releases_url": "http://api.github.com/repos/hello/world/releases{/id}",
276 | "ssh_url": "git@github.com:hello/world.git",
277 | "stargazers_url": "http://api.github.com/repos/hello/world/stargazers",
278 | "statuses_url": "http://api.github.com/repos/hello/world/statuses/{sha}",
279 | "subscribers_url": "http://api.github.com/repos/hello/world/subscribers",
280 | "subscription_url": "http://api.github.com/repos/hello/world/subscription",
281 | "tags_url": "http://api.github.com/repos/hello/world/tags",
282 | "teams_url": "http://api.github.com/repos/hello/world/teams",
283 | "trees_url": "http://api.github.com/repos/hello/world/git/trees{/sha}",
284 | "clone_url": "https://github.com/hello/world.git",
285 | "mirror_url": "git:git.example.com/hello/world",
286 | "hooks_url": "http://api.github.com/repos/hello/world/hooks",
287 | "svn_url": "https://svn.github.com/hello/world",
288 | "homepage": "https://github.com",
289 | "language": null,
290 | "forks_count": 9,
291 | "stargazers_count": 80,
292 | "watchers_count": 80,
293 | "size": 108,
294 | "default_branch": "master",
295 | "open_issues_count": 0,
296 | "is_template": true,
297 | "topics": [
298 | "octocat",
299 | "atom",
300 | "electron",
301 | "api"
302 | ],
303 | "has_issues": true,
304 | "has_projects": true,
305 | "has_wiki": true,
306 | "has_pages": false,
307 | "has_downloads": true,
308 | "archived": false,
309 | "disabled": false,
310 | "pushed_at": "2011-01-26T19:06:43Z",
311 | "created_at": "2011-01-26T19:01:12Z",
312 | "updated_at": "2011-01-26T19:14:43Z",
313 | "permissions": {
314 | "admin": false,
315 | "push": false,
316 | "pull": true
317 | },
318 | "allow_rebase_merge": true,
319 | "template_repository": null,
320 | "allow_squash_merge": true,
321 | "allow_merge_commit": true,
322 | "subscribers_count": 42,
323 | "network_count": 0
324 | }
325 | },
326 | "base": {
327 | "label": "octocat:master",
328 | "ref": "master",
329 | "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
330 | "user": {
331 | "login": "octocat",
332 | "id": 1,
333 | "node_id": "MDQ6VXNlcjE=",
334 | "avatar_url": "https://github.com/images/error/octocat_happy.gif",
335 | "gravatar_id": "",
336 | "url": "https://api.github.com/users/octocat",
337 | "html_url": "https://github.com/octocat",
338 | "followers_url": "https://api.github.com/users/octocat/followers",
339 | "following_url": "https://api.github.com/users/octocat/following{/other_user}",
340 | "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
341 | "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
342 | "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
343 | "organizations_url": "https://api.github.com/users/octocat/orgs",
344 | "repos_url": "https://api.github.com/users/octocat/repos",
345 | "events_url": "https://api.github.com/users/octocat/events{/privacy}",
346 | "received_events_url": "https://api.github.com/users/octocat/received_events",
347 | "type": "User",
348 | "site_admin": false
349 | },
350 | "repo": {
351 | "id": 1296269,
352 | "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
353 | "name": "Hello-World",
354 | "full_name": "hello/world",
355 | "owner": {
356 | "login": "octocat",
357 | "id": 1,
358 | "node_id": "MDQ6VXNlcjE=",
359 | "avatar_url": "https://github.com/images/error/octocat_happy.gif",
360 | "gravatar_id": "",
361 | "url": "https://api.github.com/users/octocat",
362 | "html_url": "https://github.com/octocat",
363 | "followers_url": "https://api.github.com/users/octocat/followers",
364 | "following_url": "https://api.github.com/users/octocat/following{/other_user}",
365 | "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
366 | "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
367 | "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
368 | "organizations_url": "https://api.github.com/users/octocat/orgs",
369 | "repos_url": "https://api.github.com/users/octocat/repos",
370 | "events_url": "https://api.github.com/users/octocat/events{/privacy}",
371 | "received_events_url": "https://api.github.com/users/octocat/received_events",
372 | "type": "User",
373 | "site_admin": false
374 | },
375 | "private": false,
376 | "html_url": "https://github.com/hello/world",
377 | "description": "This your first repo!",
378 | "fork": false,
379 | "url": "https://api.github.com/repos/hello/world",
380 | "archive_url": "http://api.github.com/repos/hello/world/{archive_format}{/ref}",
381 | "assignees_url": "http://api.github.com/repos/hello/world/assignees{/user}",
382 | "blobs_url": "http://api.github.com/repos/hello/world/git/blobs{/sha}",
383 | "branches_url": "http://api.github.com/repos/hello/world/branches{/branch}",
384 | "collaborators_url": "http://api.github.com/repos/hello/world/collaborators{/collaborator}",
385 | "comments_url": "http://api.github.com/repos/hello/world/comments{/number}",
386 | "commits_url": "http://api.github.com/repos/hello/world/commits{/sha}",
387 | "compare_url": "http://api.github.com/repos/hello/world/compare/{base}...{head}",
388 | "contents_url": "http://api.github.com/repos/hello/world/contents/{+path}",
389 | "contributors_url": "http://api.github.com/repos/hello/world/contributors",
390 | "deployments_url": "http://api.github.com/repos/hello/world/deployments",
391 | "downloads_url": "http://api.github.com/repos/hello/world/downloads",
392 | "events_url": "http://api.github.com/repos/hello/world/events",
393 | "forks_url": "http://api.github.com/repos/hello/world/forks",
394 | "git_commits_url": "http://api.github.com/repos/hello/world/git/commits{/sha}",
395 | "git_refs_url": "http://api.github.com/repos/hello/world/git/refs{/sha}",
396 | "git_tags_url": "http://api.github.com/repos/hello/world/git/tags{/sha}",
397 | "git_url": "git:github.com/hello/world.git",
398 | "issue_comment_url": "http://api.github.com/repos/hello/world/issues/comments{/number}",
399 | "issue_events_url": "http://api.github.com/repos/hello/world/issues/events{/number}",
400 | "issues_url": "http://api.github.com/repos/hello/world/issues{/number}",
401 | "keys_url": "http://api.github.com/repos/hello/world/keys{/key_id}",
402 | "labels_url": "http://api.github.com/repos/hello/world/labels{/name}",
403 | "languages_url": "http://api.github.com/repos/hello/world/languages",
404 | "merges_url": "http://api.github.com/repos/hello/world/merges",
405 | "milestones_url": "http://api.github.com/repos/hello/world/milestones{/number}",
406 | "notifications_url": "http://api.github.com/repos/hello/world/notifications{?since,all,participating}",
407 | "pulls_url": "http://api.github.com/repos/hello/world/pulls{/number}",
408 | "releases_url": "http://api.github.com/repos/hello/world/releases{/id}",
409 | "ssh_url": "git@github.com:hello/world.git",
410 | "stargazers_url": "http://api.github.com/repos/hello/world/stargazers",
411 | "statuses_url": "http://api.github.com/repos/hello/world/statuses/{sha}",
412 | "subscribers_url": "http://api.github.com/repos/hello/world/subscribers",
413 | "subscription_url": "http://api.github.com/repos/hello/world/subscription",
414 | "tags_url": "http://api.github.com/repos/hello/world/tags",
415 | "teams_url": "http://api.github.com/repos/hello/world/teams",
416 | "trees_url": "http://api.github.com/repos/hello/world/git/trees{/sha}",
417 | "clone_url": "https://github.com/hello/world.git",
418 | "mirror_url": "git:git.example.com/hello/world",
419 | "hooks_url": "http://api.github.com/repos/hello/world/hooks",
420 | "svn_url": "https://svn.github.com/hello/world",
421 | "homepage": "https://github.com",
422 | "language": null,
423 | "forks_count": 9,
424 | "stargazers_count": 80,
425 | "watchers_count": 80,
426 | "size": 108,
427 | "default_branch": "master",
428 | "open_issues_count": 0,
429 | "is_template": true,
430 | "topics": [
431 | "octocat",
432 | "atom",
433 | "electron",
434 | "api"
435 | ],
436 | "has_issues": true,
437 | "has_projects": true,
438 | "has_wiki": true,
439 | "has_pages": false,
440 | "has_downloads": true,
441 | "archived": false,
442 | "disabled": false,
443 | "pushed_at": "2011-01-26T19:06:43Z",
444 | "created_at": "2011-01-26T19:01:12Z",
445 | "updated_at": "2011-01-26T19:14:43Z",
446 | "permissions": {
447 | "admin": false,
448 | "push": false,
449 | "pull": true
450 | },
451 | "allow_rebase_merge": true,
452 | "template_repository": null,
453 | "allow_squash_merge": true,
454 | "allow_merge_commit": true,
455 | "subscribers_count": 42,
456 | "network_count": 0
457 | }
458 | },
459 | "_links": {
460 | "self": {
461 | "href": "https://api.github.com/repos/hello/world/pulls/1347"
462 | },
463 | "html": {
464 | "href": "https://github.com/hello/world/pull/1347"
465 | },
466 | "issue": {
467 | "href": "https://api.github.com/repos/hello/world/issues/1347"
468 | },
469 | "comments": {
470 | "href": "https://api.github.com/repos/hello/world/issues/1347/comments"
471 | },
472 | "review_comments": {
473 | "href": "https://api.github.com/repos/hello/world/pulls/1347/comments"
474 | },
475 | "review_comment": {
476 | "href": "https://api.github.com/repos/hello/world/pulls/comments{/number}"
477 | },
478 | "commits": {
479 | "href": "https://api.github.com/repos/hello/world/pulls/1347/commits"
480 | },
481 | "statuses": {
482 | "href": "https://api.github.com/repos/hello/world/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e"
483 | }
484 | },
485 | "author_association": "OWNER",
486 | "draft": false,
487 | "merged": false,
488 | "mergeable": true,
489 | "rebaseable": true,
490 | "mergeable_state": "clean",
491 | "merged_by": {
492 | "login": "octocat",
493 | "id": 1,
494 | "node_id": "MDQ6VXNlcjE=",
495 | "avatar_url": "https://github.com/images/error/octocat_happy.gif",
496 | "gravatar_id": "",
497 | "url": "https://api.github.com/users/octocat",
498 | "html_url": "https://github.com/octocat",
499 | "followers_url": "https://api.github.com/users/octocat/followers",
500 | "following_url": "https://api.github.com/users/octocat/following{/other_user}",
501 | "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
502 | "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
503 | "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
504 | "organizations_url": "https://api.github.com/users/octocat/orgs",
505 | "repos_url": "https://api.github.com/users/octocat/repos",
506 | "events_url": "https://api.github.com/users/octocat/events{/privacy}",
507 | "received_events_url": "https://api.github.com/users/octocat/received_events",
508 | "type": "User",
509 | "site_admin": false
510 | },
511 | "comments": 10,
512 | "review_comments": 0,
513 | "maintainer_can_modify": true,
514 | "commits": 3,
515 | "additions": 100,
516 | "deletions": 3,
517 | "changed_files": 5
518 | }
--------------------------------------------------------------------------------