├── .commitlintrc ├── .editorconfig ├── .eslintrc ├── .github ├── CODEOWNERS ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── card-labeler.yml ├── config.yml ├── labeler.yml ├── no-response.yml ├── pr-labeler.yml ├── pull_request_template.md ├── release-drafter.yml ├── stale.yml ├── workflow-details.json ├── workflow-settings.json └── workflows │ ├── add-release-tag.yml │ ├── add-test-tag.yml │ ├── check-warnings.yml │ ├── ci.yml │ ├── issue-opened.yml │ ├── pr-opened.yml │ ├── pr-updated.yml │ ├── project-card-moved.yml │ ├── sync-workflows.yml │ ├── toc.yml │ └── update-dependencies.yml ├── .gitignore ├── .husky ├── .gitignore ├── commit-msg └── pre-commit ├── .lintstagedrc ├── .releasegarc ├── LICENSE ├── README.ja.md ├── README.md ├── _config.yml ├── action.yml ├── package.json ├── rollup.config.mjs ├── samples ├── README.horizontal.md └── README.not-folding.md ├── src ├── constant.ts ├── fixtures │ ├── doctoc │ │ ├── README.create1.md │ │ ├── README.create2.md │ │ ├── README.horizontal.md │ │ ├── README.not.update.md │ │ ├── README.params.md │ │ ├── README.skip.md │ │ ├── README.toc-me.md │ │ ├── README.update.md │ │ └── expected │ │ │ ├── README.create1.md │ │ │ ├── README.create2.md │ │ │ ├── README.horizontal1.md │ │ │ ├── README.horizontal2.md │ │ │ ├── README.params.md │ │ │ ├── README.toc-me.md │ │ │ ├── README.update.md │ │ │ ├── README.update.options.md │ │ │ └── README.update.wrap.md │ ├── issues.comment.create.json │ ├── pulls.get.json │ ├── pulls.list.json │ ├── pulls.update.json │ ├── repos.get.json │ ├── repos.git.blobs.json │ ├── repos.git.commits.get.json │ ├── repos.git.commits.json │ ├── repos.git.refs.create.json │ ├── repos.git.refs.update.json │ ├── repos.git.trees.json │ └── test.md ├── main.ts ├── setup.ts └── utils │ ├── doctoc.test.ts │ ├── doctoc.ts │ ├── misc.test.ts │ ├── misc.ts │ ├── process.test.ts │ └── transform.ts ├── tsconfig.json ├── vite.config.ts └── yarn.lock /.commitlintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "@commitlint/config-conventional" 4 | ] 5 | } -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @technote-space 2 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.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/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: https://paypal.me/technote0space -------------------------------------------------------------------------------- /.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/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/card-labeler.yml: -------------------------------------------------------------------------------- 1 | Backlog: 2 | 'In progress': 3 | - 'Status: In Progress' 4 | -------------------------------------------------------------------------------- /.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/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 | -------------------------------------------------------------------------------- /.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/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 | -------------------------------------------------------------------------------- /.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/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/workflow-details.json: -------------------------------------------------------------------------------- 1 | { 2 | "TOC_TARGET_PATHS": "README*.md,samples/*.md" 3 | } 4 | -------------------------------------------------------------------------------- /.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/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 | -------------------------------------------------------------------------------- /.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/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | on: push 2 | 3 | concurrency: 4 | group: ${{ github.workflow }}-${{ github.ref }} 5 | 6 | name: CI 7 | 8 | jobs: 9 | eslint: 10 | name: ESLint 11 | runs-on: ubuntu-latest 12 | timeout-minutes: 5 13 | env: 14 | LINT: 1 15 | steps: 16 | - name: Set running flag 17 | run: echo "RUNNING=1" >> $GITHUB_ENV 18 | - uses: actions/checkout@v3 19 | - uses: technote-space/get-git-comment-action@v1 20 | - uses: technote-space/get-diff-action@v6 21 | with: 22 | PATTERNS: +(src|__tests__)/**/*.+(js|ts) 23 | FILES: | 24 | yarn.lock 25 | .eslintrc 26 | if: "! contains(env.COMMIT_MESSAGE, '[skip ci]') && ! contains(env.COMMIT_MESSAGE, '[ci skip]')" 27 | - name: Set running flag 28 | run: echo "RUNNING=" >> $GITHUB_ENV 29 | if: "! env.GIT_DIFF" 30 | 31 | - uses: actions/setup-node@v3 32 | with: 33 | node-version: 16 34 | cache: yarn 35 | if: env.RUNNING 36 | - name: Install Package dependencies 37 | run: yarn install 38 | if: env.RUNNING 39 | - name: Check code style 40 | run: yarn eslint ${{ env.GIT_DIFF_FILTERED }} 41 | if: env.RUNNING && !env.MATCHED_FILES 42 | - name: Check code style 43 | run: yarn lint 44 | if: env.RUNNING && env.MATCHED_FILES 45 | 46 | cover: 47 | name: Coverage 48 | needs: eslint 49 | runs-on: ${{matrix.os}} 50 | timeout-minutes: 10 51 | strategy: 52 | matrix: 53 | os: [ubuntu-20.04, ubuntu-22.04, ubuntu-latest, macos-latest] 54 | steps: 55 | - name: Set running flag 56 | run: echo "RUNNING=1" >> $GITHUB_ENV 57 | - uses: actions/checkout@v3 58 | - uses: technote-space/get-git-comment-action@v1 59 | - uses: technote-space/get-diff-action@v6 60 | with: 61 | PATTERNS: +(src|__tests__)/**/*.+(js|ts|snap) 62 | FILES: | 63 | yarn.lock 64 | jest.config.js 65 | vite.config.ts 66 | if: "! contains(env.COMMIT_MESSAGE, '[skip ci]') && ! contains(env.COMMIT_MESSAGE, '[ci skip]')" 67 | - name: Set running flag 68 | run: echo "RUNNING=" >> $GITHUB_ENV 69 | if: "! env.GIT_DIFF" 70 | - name: Set running flag 71 | if: "matrix.os == 'ubuntu-latest' && ! startsWith(github.ref, 'refs/tags/') && github.event.base_ref == format('refs/heads/{0}', github.event.repository.default_branch)" 72 | run: echo "RUNNING=1" >> $GITHUB_ENV 73 | - name: Set running flag 74 | if: "matrix.os == 'ubuntu-latest' && ! startsWith(github.ref, 'refs/tags/') && startsWith(github.base_ref, 'refs/heads/develop/v')" 75 | run: echo "RUNNING=1" >> $GITHUB_ENV 76 | - name: Set running flag 77 | if: matrix.os == 'ubuntu-latest' && startsWith(github.ref, 'refs/tags/v') 78 | run: echo "RUNNING=1" >> $GITHUB_ENV 79 | - name: Set running flag 80 | run: | 81 | if [[ ! -f package.json ]] || ! < package.json jq -r '.scripts | keys[]' | grep -qe '^cover$'; then 82 | echo "RUNNING=" >> $GITHUB_ENV 83 | fi 84 | 85 | - uses: actions/setup-node@v3 86 | with: 87 | node-version: 16 88 | cache: yarn 89 | if: env.RUNNING 90 | - name: Install Package dependencies 91 | run: yarn install 92 | if: env.RUNNING 93 | - name: Run tests 94 | run: yarn cover 95 | if: env.RUNNING 96 | - name: Codecov 97 | run: | 98 | if [ -n "$CODECOV_TOKEN" ]; then 99 | curl -s https://codecov.io/bash | bash -s -- -t $CODECOV_TOKEN -f $COVERAGE_FILE 100 | fi 101 | env: 102 | CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} 103 | COVERAGE_FILE: ./coverage/lcov.info 104 | if: env.RUNNING && matrix.os == 'ubuntu-latest' 105 | 106 | release: 107 | name: Release GitHub Actions 108 | needs: cover 109 | runs-on: ubuntu-latest 110 | timeout-minutes: 5 111 | if: startsWith(github.ref, 'refs/tags/') 112 | steps: 113 | - uses: actions/checkout@v3 114 | - uses: actions/setup-node@v3 115 | with: 116 | node-version: 16 117 | cache: yarn 118 | 119 | - uses: technote-space/load-config-action@v1 120 | with: 121 | CONFIG_FILENAME: workflow-settings.json, workflow-details.json 122 | IGNORE_WARNING: 'true' 123 | - name: Release GitHub Actions 124 | uses: technote-space/release-github-actions@v8 125 | with: 126 | OUTPUT_BUILD_INFO_FILENAME: build.json 127 | TEST_TAG_PREFIX: test/ 128 | ORIGINAL_TAG_PREFIX: original/ 129 | CLEAN_TEST_TAG: true 130 | DELETE_NODE_MODULES: ${{ env.RELEASE_GA_DELETE_NODE_MODULES }} 131 | 132 | package: 133 | name: Publish Package 134 | needs: cover 135 | runs-on: ubuntu-latest 136 | timeout-minutes: 5 137 | if: startsWith(github.ref, 'refs/tags/v') 138 | strategy: 139 | matrix: 140 | target: ['npm', 'gpr'] 141 | steps: 142 | - name: Set running flag 143 | run: echo "RUNNING=1" >> $GITHUB_ENV 144 | - name: Set running flag 145 | run: | 146 | if [ -z "$NPM_AUTH_TOKEN" ]; then 147 | echo "RUNNING=" >> $GITHUB_ENV 148 | fi 149 | env: 150 | NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} 151 | - uses: actions/checkout@v3 152 | if: env.RUNNING 153 | - name: Check package version 154 | uses: technote-space/package-version-check-action@v1 155 | with: 156 | COMMIT_DISABLED: 1 157 | if: env.RUNNING 158 | - name: Set running flag 159 | run: npx can-npm-publish || echo "RUNNING=" >> $GITHUB_ENV 160 | if: env.RUNNING && matrix.target == 'npm' 161 | - name: Set running flag 162 | run: | 163 | LATEST=`npm view . version` 2> /dev/null || : 164 | CURRENT=`cat package.json | jq -r .version` 165 | if [ "$LATEST" = "$CURRENT" ]; then 166 | echo "RUNNING=" >> $GITHUB_ENV 167 | fi 168 | env: 169 | NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 170 | if: env.RUNNING && matrix.target == 'gpr' 171 | 172 | - name: Setup Node.js 173 | uses: actions/setup-node@v3 174 | with: 175 | node-version: 16 176 | registry-url: https://registry.npmjs.org/ 177 | cache: yarn 178 | if: env.RUNNING && matrix.target == 'npm' 179 | - name: Setup Node.js 180 | uses: actions/setup-node@v3 181 | with: 182 | node-version: 16 183 | registry-url: https://npm.pkg.github.com 184 | cache: yarn 185 | if: env.RUNNING && matrix.target == 'gpr' 186 | - name: Install Package dependencies 187 | run: yarn install 188 | if: env.RUNNING 189 | - name: Build 190 | run: yarn build 191 | if: env.RUNNING 192 | - name: Publish 193 | run: | 194 | npm config set //registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN 195 | npm publish 196 | env: 197 | NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} 198 | if: env.RUNNING && matrix.target == 'npm' 199 | - name: Publish 200 | run: | 201 | npm publish 202 | env: 203 | NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 204 | if: env.RUNNING && matrix.target == 'gpr' 205 | 206 | publishRelease: 207 | name: Create Release 208 | needs: [release, package] 209 | runs-on: ubuntu-latest 210 | timeout-minutes: 5 211 | steps: 212 | - name: Get version 213 | run: echo "TAG_NAME=${HEAD_REF#refs/tags/}" >> $GITHUB_ENV 214 | env: 215 | HEAD_REF: ${{ github.ref }} 216 | - name: Create Release 217 | id: drafter 218 | uses: technote-space/release-drafter@v6 219 | with: 220 | GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} 221 | DRAFT: false 222 | NAME: ${{ env.TAG_NAME }} 223 | TAG: ${{ env.TAG_NAME }} 224 | - uses: 8398a7/action-slack@v3 225 | with: 226 | status: ${{ job.status }} 227 | text: ${{ format('<{0}>', steps.drafter.outputs.html_url) }} 228 | env: 229 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} 230 | if: success() && env.SLACK_WEBHOOK_URL 231 | 232 | slack: 233 | name: Slack 234 | needs: publishRelease 235 | runs-on: ubuntu-latest 236 | timeout-minutes: 3 237 | if: always() 238 | steps: 239 | - uses: technote-space/workflow-conclusion-action@v3 240 | - uses: 8398a7/action-slack@v3 241 | with: 242 | status: failure 243 | env: 244 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} 245 | if: env.WORKFLOW_CONCLUSION == 'failure' && env.SLACK_WEBHOOK_URL 246 | -------------------------------------------------------------------------------- /.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/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/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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.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/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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | /.vscode 3 | /node_modules 4 | /coverage 5 | /lib 6 | /.work 7 | .eslintcache 8 | .env 9 | -------------------------------------------------------------------------------- /.husky/.gitignore: -------------------------------------------------------------------------------- 1 | _ 2 | -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | yarn commitlint -- --edit $1 5 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | yarn lint-staged 5 | -------------------------------------------------------------------------------- /.lintstagedrc: -------------------------------------------------------------------------------- 1 | { 2 | "*.{js,jsx,ts,tsx}": "yarn lint:fix" 3 | } -------------------------------------------------------------------------------- /.releasegarc: -------------------------------------------------------------------------------- 1 | { 2 | "inputs": { 3 | "OUTPUT_BUILD_INFO_FILENAME": "build.json", 4 | "TEST_TAG_PREFIX": "test/", 5 | "CLEAN_TEST_TAG": "true" 6 | } 7 | } -------------------------------------------------------------------------------- /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. -------------------------------------------------------------------------------- /README.ja.md: -------------------------------------------------------------------------------- 1 | # TOC Generator 2 | 3 | [![CI Status](https://github.com/technote-space/toc-generator/workflows/CI/badge.svg)](https://github.com/technote-space/toc-generator/actions) 4 | [![codecov](https://codecov.io/gh/technote-space/toc-generator/branch/main/graph/badge.svg)](https://codecov.io/gh/technote-space/toc-generator) 5 | [![CodeFactor](https://www.codefactor.io/repository/github/technote-space/toc-generator/badge)](https://www.codefactor.io/repository/github/technote-space/toc-generator) 6 | [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](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 | ![behavior](https://raw.githubusercontent.com/technote-space/toc-generator/images/screenshot.gif) 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 | ![create pr](https://raw.githubusercontent.com/technote-space/toc-generator/images/create_pr.png) 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TOC Generator 2 | 3 | [![CI Status](https://github.com/technote-space/toc-generator/workflows/CI/badge.svg)](https://github.com/technote-space/toc-generator/actions) 4 | [![codecov](https://codecov.io/gh/technote-space/toc-generator/branch/main/graph/badge.svg)](https://codecov.io/gh/technote-space/toc-generator) 5 | [![CodeFactor](https://www.codefactor.io/repository/github/technote-space/toc-generator/badge)](https://www.codefactor.io/repository/github/technote-space/toc-generator) 6 | [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](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 | 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 | ## Table of Contents 14 | 15 | 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 | ![behavior](https://raw.githubusercontent.com/technote-space/toc-generator/images/screenshot.gif) 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 | ![create pr](https://raw.githubusercontent.com/technote-space/toc-generator/images/create_pr.png) 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 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-architect 2 | 3 | # Google Analytics 4 | google_analytics: UA-78163306-3 -------------------------------------------------------------------------------- /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: ' 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 | ![behavior](https://raw.githubusercontent.com/technote-space/toc-generator/images/screenshot.gif) 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 | ![behavior](https://raw.githubusercontent.com/technote-space/toc-generator/images/screenshot.gif) 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)|` 4 | 5 | 6 | ## Test1 7 | ## Test2 8 | -------------------------------------------------------------------------------- /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/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.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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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.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 | -------------------------------------------------------------------------------- /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.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 | -------------------------------------------------------------------------------- /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.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/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.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/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.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.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/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 | } -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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/repos.git.blobs.json: -------------------------------------------------------------------------------- 1 | { 2 | "url": "https://api.github.com/repos/hello/world/git/blobs/3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15", 3 | "sha": "3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15" 4 | } -------------------------------------------------------------------------------- /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/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 | } -------------------------------------------------------------------------------- /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/test.md: -------------------------------------------------------------------------------- 1 | test -------------------------------------------------------------------------------- /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/setup.ts: -------------------------------------------------------------------------------- 1 | import { setupGlobal } from '@technote-space/github-action-test-helper'; 2 | 3 | setupGlobal(); 4 | -------------------------------------------------------------------------------- /src/utils/doctoc.test.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-magic-numbers */ 2 | import fs from 'fs'; 3 | import { resolve } from 'path'; 4 | import { Logger } from '@technote-space/github-action-log-helper'; 5 | import { testEnv } from '@technote-space/github-action-test-helper'; 6 | import { beforeEach, describe, expect, it, vi } from 'vitest'; 7 | import { 8 | transformAndSave, 9 | executeDoctoc, 10 | } from './doctoc'; 11 | 12 | const rootDir = resolve(__dirname, '../..'); 13 | const doctocDir = resolve(__dirname, '../fixtures/doctoc'); 14 | const logger = new Logger(); 15 | const title = '**test title**'; 16 | beforeEach(() => { 17 | vi.spyOn(fs, 'writeFileSync').mockImplementation(() => undefined); 18 | }); 19 | 20 | describe('transformAndSave', () => { 21 | testEnv(rootDir); 22 | 23 | it('should return empty', () => { 24 | expect(transformAndSave([], title)).toEqual({ changed: [], unchanged: [] }); 25 | }); 26 | 27 | it('should run doctoc', () => { 28 | expect(transformAndSave([{ path: resolve(doctocDir, 'README.update.md') }], title)).toEqual({ 29 | changed: [ 30 | { 31 | data: fs.readFileSync(resolve(doctocDir, 'expected/README.update.md'), 'utf8'), 32 | path: resolve(doctocDir, 'README.update.md'), 33 | transformed: true, 34 | }, 35 | ], 36 | unchanged: [], 37 | }); 38 | }); 39 | 40 | it('should not run doctoc', () => { 41 | expect(transformAndSave([{ path: resolve(doctocDir, 'README.not.update.md') }], title)).toEqual({ 42 | changed: [], 43 | unchanged: [ 44 | { 45 | data: '', 46 | path: resolve(doctocDir, 'README.not.update.md'), 47 | transformed: false, 48 | }, 49 | ], 50 | }); 51 | }); 52 | 53 | it('mixed', () => { 54 | expect(transformAndSave([ 55 | { path: resolve(doctocDir, 'README.create1.md') }, 56 | { path: resolve(doctocDir, 'README.create2.md') }, 57 | { path: resolve(doctocDir, 'README.update.md') }, 58 | { path: resolve(doctocDir, 'README.not.update.md') }, 59 | { path: resolve(doctocDir, 'README.toc-me.md') }, 60 | ], title)).toEqual({ 61 | changed: [ 62 | { 63 | data: fs.readFileSync(resolve(doctocDir, 'expected/README.create1.md'), 'utf8'), 64 | path: resolve(doctocDir, 'README.create1.md'), 65 | transformed: true, 66 | }, 67 | { 68 | data: fs.readFileSync(resolve(doctocDir, 'expected/README.create2.md'), 'utf8'), 69 | path: resolve(doctocDir, 'README.create2.md'), 70 | transformed: true, 71 | }, 72 | { 73 | data: fs.readFileSync(resolve(doctocDir, 'expected/README.update.md'), 'utf8'), 74 | path: resolve(doctocDir, 'README.update.md'), 75 | transformed: true, 76 | }, 77 | { 78 | data: fs.readFileSync(resolve(doctocDir, 'expected/README.toc-me.md'), 'utf8'), 79 | path: resolve(doctocDir, 'README.toc-me.md'), 80 | transformed: true, 81 | }, 82 | ], 83 | unchanged: [ 84 | { 85 | data: '', 86 | path: resolve(doctocDir, 'README.not.update.md'), 87 | transformed: false, 88 | }, 89 | ], 90 | }); 91 | }); 92 | 93 | it('should wrap', () => { 94 | process.env.INPUT_FOLDING = 'true'; 95 | 96 | expect(transformAndSave([{ path: resolve(doctocDir, 'README.update.md') }], title)).toEqual({ 97 | changed: [ 98 | { 99 | data: fs.readFileSync(resolve(doctocDir, 'expected/README.update.wrap.md'), 'utf8'), 100 | path: resolve(doctocDir, 'README.update.md'), 101 | transformed: true, 102 | }, 103 | ], 104 | unchanged: [], 105 | }); 106 | 107 | expect(transformAndSave([{ path: resolve(doctocDir, 'README.update.md') }], 'test title')).toEqual({ 108 | changed: [ 109 | { 110 | data: fs.readFileSync(resolve(doctocDir, 'expected/README.update.wrap.md'), 'utf8'), 111 | path: resolve(doctocDir, 'README.update.md'), 112 | transformed: true, 113 | }, 114 | ], 115 | unchanged: [], 116 | }); 117 | }); 118 | 119 | it('should set options', () => { 120 | process.env.INPUT_FOLDING = 'true'; 121 | process.env.INPUT_MAX_HEADER_LEVEL = '3'; 122 | process.env.INPUT_ENTRY_PREFIX = '☆'; 123 | process.env.INPUT_FOOTER = '*generated with [TOC Generator](https://github.com/technote-space/toc-generator)*'; 124 | 125 | expect(transformAndSave([{ path: resolve(doctocDir, 'README.update.md') }], title)).toEqual({ 126 | changed: [ 127 | { 128 | data: fs.readFileSync(resolve(doctocDir, 'expected/README.update.options.md'), 'utf8'), 129 | path: resolve(doctocDir, 'README.update.md'), 130 | transformed: true, 131 | }, 132 | ], 133 | unchanged: [], 134 | }); 135 | }); 136 | 137 | it('should run doctoc with custom mode', () => { 138 | process.env.INPUT_CUSTOM_MODE = 'true'; 139 | process.env.INPUT_CUSTOM_TEMPLATE = '

${ITEMS}

'; 140 | process.env.INPUT_ITEM_TEMPLATE = '[${TEXT}]'; 141 | process.env.INPUT_SEPARATOR = '・'; 142 | expect(transformAndSave([{ path: resolve(doctocDir, 'README.horizontal.md') }], title)).toEqual({ 143 | changed: [ 144 | { 145 | data: fs.readFileSync(resolve(doctocDir, 'expected/README.horizontal1.md'), 'utf8'), 146 | path: resolve(doctocDir, 'README.horizontal.md'), 147 | transformed: true, 148 | }, 149 | ], 150 | unchanged: [], 151 | }); 152 | }); 153 | 154 | it('should run doctoc with html mode (deprecated)', () => { 155 | process.env.INPUT_HTML_MODE = 'true'; 156 | expect(transformAndSave([{ path: resolve(doctocDir, 'README.horizontal.md') }], title)).toEqual({ 157 | changed: [ 158 | { 159 | data: fs.readFileSync(resolve(doctocDir, 'expected/README.horizontal2.md'), 'utf8'), 160 | path: resolve(doctocDir, 'README.horizontal.md'), 161 | transformed: true, 162 | }, 163 | ], 164 | unchanged: [], 165 | }); 166 | }); 167 | 168 | it('should override options', () => { 169 | process.env.INPUT_FOLDING = 'true'; 170 | process.env.INPUT_MAX_HEADER_LEVEL = '3'; 171 | process.env.INPUT_ENTRY_PREFIX = '☆'; 172 | 173 | expect(transformAndSave([{ path: resolve(doctocDir, 'README.params.md') }], title)).toEqual({ 174 | changed: [ 175 | { 176 | data: fs.readFileSync(resolve(doctocDir, 'expected/README.params.md'), 'utf8'), 177 | path: resolve(doctocDir, 'README.params.md'), 178 | transformed: true, 179 | }, 180 | ], 181 | unchanged: [], 182 | }); 183 | }); 184 | }); 185 | 186 | describe('executeDoctoc', () => { 187 | testEnv(rootDir); 188 | 189 | it('should execute doctoc 1', () => { 190 | expect(executeDoctoc([ 191 | doctocDir, 192 | ], title, logger)).toEqual({ 193 | changed: [ 194 | resolve(doctocDir, 'README.create1.md'), 195 | resolve(doctocDir, 'README.create2.md'), 196 | resolve(doctocDir, 'README.horizontal.md'), 197 | resolve(doctocDir, 'README.params.md'), 198 | resolve(doctocDir, 'README.toc-me.md'), 199 | resolve(doctocDir, 'README.update.md'), 200 | resolve(doctocDir, 'expected/README.horizontal1.md'), 201 | resolve(doctocDir, 'expected/README.horizontal2.md'), 202 | resolve(doctocDir, 'expected/README.params.md'), 203 | resolve(doctocDir, 'expected/README.update.options.md'), 204 | resolve(doctocDir, 'expected/README.update.wrap.md'), 205 | ], 206 | unchanged: [ 207 | resolve(doctocDir, 'README.not.update.md'), 208 | resolve(doctocDir, 'README.skip.md'), 209 | resolve(doctocDir, 'expected/README.create1.md'), 210 | resolve(doctocDir, 'expected/README.create2.md'), 211 | resolve(doctocDir, 'expected/README.toc-me.md'), 212 | resolve(doctocDir, 'expected/README.update.md'), 213 | ], 214 | }); 215 | }); 216 | 217 | it('should execute doctoc 2', () => { 218 | expect(executeDoctoc([ 219 | resolve(doctocDir, 'README*.md'), 220 | ], title, logger)).toEqual({ 221 | changed: [ 222 | resolve(doctocDir, 'README.create1.md'), 223 | resolve(doctocDir, 'README.create2.md'), 224 | resolve(doctocDir, 'README.horizontal.md'), 225 | resolve(doctocDir, 'README.params.md'), 226 | resolve(doctocDir, 'README.toc-me.md'), 227 | resolve(doctocDir, 'README.update.md'), 228 | ], 229 | unchanged: [ 230 | resolve(doctocDir, 'README.not.update.md'), 231 | resolve(doctocDir, 'README.skip.md'), 232 | ], 233 | }); 234 | }); 235 | 236 | it('should not execute doctoc', () => { 237 | expect(executeDoctoc([ 238 | resolve(doctocDir, 'tmp'), 239 | resolve(doctocDir, 'README-test*.md'), 240 | ], title, logger)).toEqual({ 241 | changed: [], 242 | unchanged: [], 243 | }); 244 | }); 245 | }); 246 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/utils/misc.test.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-magic-numbers */ 2 | import os from 'os'; 3 | import path from 'path'; 4 | import { testEnv } from '@technote-space/github-action-test-helper'; 5 | import { describe, expect, it, vi } from 'vitest'; 6 | import { TARGET_EVENTS } from '../constant'; 7 | import { 8 | replaceDirectory, 9 | getRunnerArguments, 10 | isNoTitle, 11 | isFolding, 12 | getMaxHeaderLevel, 13 | getEntryPrefix, 14 | homeExpanded, 15 | cleanPath, 16 | getArrayInput, 17 | } from './misc'; 18 | 19 | const rootDir = path.resolve(__dirname, '../..'); 20 | 21 | describe('replaceDirectory', () => { 22 | testEnv(rootDir); 23 | 24 | it('should replace working directory', () => { 25 | process.env.GITHUB_WORKSPACE = 'test-dir'; 26 | const workDir = path.resolve('test-dir'); 27 | 28 | expect(replaceDirectory(`git -C ${workDir} fetch`)).toBe('git fetch'); 29 | expect(replaceDirectory(`ls ${workDir}`)).toBe('ls [Working Directory]'); 30 | }); 31 | }); 32 | 33 | describe('getRunnerArguments', () => { 34 | testEnv(rootDir); 35 | 36 | it('should return args', () => { 37 | const args = getRunnerArguments(); 38 | delete args.logger; 39 | expect(args).toHaveProperty('executeCommands'); 40 | delete args.executeCommands; 41 | expect(args).toEqual({ 42 | rootDir: path.resolve(__dirname, '..'), 43 | actionName: 'TOC Generator', 44 | actionOwner: 'technote-space', 45 | actionRepo: 'toc-generator', 46 | checkOnlyDefaultBranch: false, 47 | commitMessage: 'chore(docs): update TOC', 48 | commitName: '', 49 | commitEmail: '', 50 | filterExtensions: [ 51 | 'md', 52 | 'markdown', 53 | ], 54 | filterGitStatus: 'M', 55 | includeLabels: [], 56 | notCreatePr: true, 57 | prBody: [ 58 | '## Base PullRequest', 59 | '', 60 | '${PR_TITLE} (${PR_NUMBER_REF})', 61 | '', 62 | '## Command results', 63 | '
', 64 | ' Details: ', 65 | '', 66 | ' ${COMMANDS_OUTPUT}', 67 | '', 68 | '
', 69 | '', 70 | '## Changed files', 71 | '
', 72 | ' ${FILES_SUMMARY}: ', 73 | '', 74 | ' ${FILES}', 75 | '', 76 | '
', 77 | '', 78 | '
', 79 | '', 80 | '[:octocat: Repo](${ACTION_URL}) | [:memo: Issues](${ACTION_URL}/issues) | [:department_store: Marketplace](${ACTION_MARKETPLACE_URL})', 81 | ].join('\n'), 82 | prBodyForDefaultBranch: '', 83 | prBodyForComment: [ 84 | '## Command results', 85 | '
', 86 | ' Details: ', 87 | '', 88 | ' ${COMMANDS_OUTPUT}', 89 | '', 90 | '
', 91 | '', 92 | '## Changed files', 93 | '
', 94 | ' ${FILES_SUMMARY}: ', 95 | '', 96 | ' ${FILES}', 97 | '', 98 | '
', 99 | '', 100 | '
', 101 | '', 102 | '[:octocat: Repo](${ACTION_URL}) | [:memo: Issues](${ACTION_URL}/issues) | [:department_store: Marketplace](${ACTION_MARKETPLACE_URL})', 103 | ].join('\n'), 104 | prBranchName: 'update-toc-${PR_ID}', 105 | prBranchNameForDefaultBranch: '', 106 | prBranchPrefix: 'toc-generator/', 107 | prBranchPrefixForDefaultBranch: '', 108 | prCloseMessage: 'This PR has been closed because it is no longer needed.', 109 | prTitle: 'chore(docs): update TOC (${PR_MERGE_REF})', 110 | prTitleForDefaultBranch: '', 111 | targetBranchPrefix: '', 112 | targetEvents: TARGET_EVENTS, 113 | signoff: false, 114 | }); 115 | }); 116 | 117 | it('should return args', () => { 118 | process.env.INPUT_COMMIT_NAME = 'test name'; 119 | process.env.INPUT_COMMIT_EMAIL = 'test email'; 120 | process.env.INPUT_COMMIT_MESSAGE = 'test message'; 121 | process.env.INPUT_PR_BRANCH_PREFIX = 'prefix/'; 122 | process.env.INPUT_PR_BRANCH_NAME = 'test-branch-${PR_ID}'; 123 | process.env.INPUT_PR_TITLE = 'test: create pull request (${PR_NUMBER})'; 124 | process.env.INPUT_PR_BODY = 'pull request body'; 125 | process.env.INPUT_PR_DEFAULT_BRANCH_PREFIX = 'prefix-default-branch/'; 126 | process.env.INPUT_PR_DEFAULT_BRANCH_NAME = 'test-default-branch-branch-${PR_ID}'; 127 | process.env.INPUT_PR_DEFAULT_BRANCH_TITLE = 'test-default-branch: create pull request (${PR_NUMBER})'; 128 | process.env.INPUT_PR_DEFAULT_BRANCH_BODY = 'pull request body (default-branch)'; 129 | process.env.INPUT_PR_COMMENT_BODY = 'pull request body (comment)'; 130 | process.env.INPUT_PR_CLOSE_MESSAGE = 'close message'; 131 | process.env.INPUT_PR_DATE_FORMAT1 = 'YYYY-MM-DD HH:mm:ss'; 132 | process.env.INPUT_PR_DATE_FORMAT2 = 'YYYY-MM-DD'; 133 | process.env.INPUT_TARGET_BRANCH_PREFIX = 'feature/'; 134 | process.env.INPUT_DELETE_PACKAGE = '1'; 135 | process.env.INPUT_INCLUDE_LABELS = 'label1, label2\nlabel3'; 136 | process.env.INPUT_TARGET_PATHS = '/'; 137 | process.env.INPUT_CREATE_PR = 'false'; 138 | process.env.INPUT_CHECK_ONLY_DEFAULT_BRANCH = 'true'; 139 | process.env.INPUT_SIGNOFF = 'true'; 140 | 141 | const args = getRunnerArguments(); 142 | delete args.logger; 143 | expect(args).toEqual({ 144 | rootDir: path.resolve(__dirname, '..'), 145 | actionName: 'TOC Generator', 146 | actionOwner: 'technote-space', 147 | actionRepo: 'toc-generator', 148 | checkOnlyDefaultBranch: true, 149 | commitName: 'test name', 150 | commitEmail: 'test email', 151 | commitMessage: 'test message', 152 | executeCommands: [], 153 | filterExtensions: [ 154 | 'md', 155 | 'markdown', 156 | ], 157 | filterGitStatus: 'M', 158 | notCreatePr: true, 159 | includeLabels: [ 160 | 'label1', 161 | 'label2', 162 | 'label3', 163 | ], 164 | prBody: 'pull request body', 165 | prBodyForDefaultBranch: 'pull request body (default-branch)', 166 | prBodyForComment: 'pull request body (comment)', 167 | prBranchName: 'test-branch-${PR_ID}', 168 | prBranchNameForDefaultBranch: 'test-default-branch-branch-${PR_ID}', 169 | prBranchPrefix: 'prefix/', 170 | prBranchPrefixForDefaultBranch: 'prefix-default-branch/', 171 | prCloseMessage: 'close message', 172 | prTitle: 'test: create pull request (${PR_NUMBER})', 173 | prTitleForDefaultBranch: 'test-default-branch: create pull request (${PR_NUMBER})', 174 | targetBranchPrefix: 'feature/', 175 | targetEvents: TARGET_EVENTS, 176 | signoff: true, 177 | }); 178 | }); 179 | }); 180 | 181 | describe('isNoTitle', () => { 182 | it('should return false', () => { 183 | expect(isNoTitle('test title')).toBe(false); 184 | }); 185 | 186 | it('should return true', () => { 187 | expect(isNoTitle('')).toBe(true); 188 | }); 189 | }); 190 | 191 | describe('isFolding', () => { 192 | testEnv(rootDir); 193 | 194 | it('should return false', () => { 195 | expect(isFolding()).toBe(false); 196 | }); 197 | 198 | it('should return true', () => { 199 | process.env.INPUT_FOLDING = 'true'; 200 | expect(isFolding()).toBe(true); 201 | }); 202 | }); 203 | 204 | describe('getMaxHeaderLevel', () => { 205 | testEnv(rootDir); 206 | 207 | it('should get max header level', () => { 208 | process.env.INPUT_MAX_HEADER_LEVEL = '3'; 209 | expect(getMaxHeaderLevel()).toBe(3); 210 | }); 211 | 212 | it('should not get max header level', () => { 213 | expect(getMaxHeaderLevel()).toBeUndefined(); 214 | }); 215 | }); 216 | 217 | describe('getEntryPrefix', () => { 218 | testEnv(rootDir); 219 | 220 | it('should get entry prefix', () => { 221 | process.env.INPUT_ENTRY_PREFIX = '*'; 222 | expect(getEntryPrefix()).toBe('*'); 223 | }); 224 | 225 | it('should not get entry prefix', () => { 226 | expect(getEntryPrefix()).toBe(''); 227 | }); 228 | }); 229 | 230 | describe('homeExpanded', () => { 231 | testEnv(rootDir); 232 | 233 | it('should return home path', () => { 234 | const spy = vi.spyOn(os, 'homedir').mockImplementation(() => '/home/test'); 235 | expect(homeExpanded('~/test.txt')).toBe('/home/test/test.txt'); 236 | spy.mockRestore(); 237 | }); 238 | 239 | it('should return absolute path', () => { 240 | process.env.GITHUB_WORKSPACE = '/test-dir/'; 241 | expect(homeExpanded('test.txt')).toBe('/test-dir/test.txt'); 242 | }); 243 | }); 244 | 245 | describe('cleanPath', () => { 246 | testEnv(rootDir); 247 | 248 | it('should return clean path', () => { 249 | const spy = vi.spyOn(os, 'homedir').mockImplementation(() => '/home/test'); 250 | expect(cleanPath('~/t e s t.txt')).toBe('/home/test/t\\ e\\ s\\ t.txt'); 251 | spy.mockRestore(); 252 | }); 253 | }); 254 | 255 | describe('getArrayInput', () => { 256 | testEnv(rootDir); 257 | 258 | it('should return array input', () => { 259 | expect(getArrayInput('OPENING_COMMENT')).toEqual([ 260 | '