/more-linked-issues-action

Link pull requests to issues via commit messages and titles

Primary LanguageJavaScriptApache License 2.0Apache-2.0

more-linked-issues-action

A GitHub Action to discover linked issues in PRs via commit messages, the PR title, or both

Read about linked issues.

Supported Events

  • pull_request

Inputs

Remember, all inputs are strings.

github-token

Required The GitHub secret token

use-commit-message

If 'true', search all messages in all of the PR's commits for linked issues. If 'false', do not.

Default: 'true'

use-pr-title

If 'true', search the PR's title for linked issues. If 'false', do not.

Default: 'true'

keywords

A comma-delimited list of keywords to recognize linked issues. These will only affect this GitHub action; GitHub itself has its own list.

Default: 'close,closes,closed,fix,fixes,fixed,resolve,resolves,resolved'

Outputs

links

A comma-delimited list of linked issues.

Behavior

GitHub does not currently (as of October 15, 2020) offer an API to link issues to pull requests. To establish the links, more-linked-issues-action appends a short section of text to the end of the pull request body (its "description"). This text contains:

  • a markdown separator
  • a list of issue references, each preceded by a GitHub-approved keyword ("Resolves")
  • an "updated on" timestamp and link to this action's homepage

The text uses a pair of HTML comments to declare its sandbox; these comments will be found upon re-run and the be removed and/or updated as appropriate.

Warning: Do not change the comments, or you will likely get duplicated information. If this happens, delete all of it manually; if the edited type is enabled for the pull_request event (see example below), it will trigger the action again.

If more-linked-issues-action previously found links, but does not find any upon re-run, it will remove the section. If it previosuly found multiple links, but some subset is not found upon re-run, it will remove the stale links from the section.

Example usage

The following uses the default settings and provides the required github-token input:

# .github/workflows/more-issue-links.yml

on:
  pull_request:
    # we use the `edited` type to detect changes to the PR title
    types: [opened, edited, synchronize, reopened]

jobs:
  link-issues:
    runs-on: ubuntu-latest
    name: Link issues found in PR title and commit message(s)
    steps:
      - id: link-issues
        uses: boneskull/more-linked-issues-action@v0.2.1
        with:
          github-token: '${{ secrets.GITHUB_TOKEN }}'
    # you likely won't need the output for anything, but here it is.
    # - name: Get comma-delimited list of found links
    #  run: echo "${{ steps.link-issues.outputs.links }}"

License

Copyright © 2020 Christopher Hiller. Licensed Apache-2.0