Skip to content

Ismoh-Games/find-linked-issues

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

find-linked-issues and more

test pull_request test pull_request_target

Marketplace action for finding the linked issues of a pull request.

Usage

Make use of GitHub's keywords to link issues to a pull request by default.
You can also do this manually in the 'development' section of the pull request sidebar on the right.

Inputs and outputs

Name INPUTS Description Default
token The GitHub token to use for authentication. required ${{ secrets.GITHUB_TOKEN }}
repository The repository to use. If linked issue is on a different repository. required ${{ github.repository }}
pull-request-number The pull request number to use. If pull requests are linked. required ${{ github.event.pull_request.number }}
pull-request-body The pull request body to search for keywords like Resolves #48. required ${{ github.event.pull_request.body }}
copy-issues-labels Copy the labels of the linked issues to the pull request. optional false
include-closed-issues Includes closed issues, when searching for linked issues. optional false
Name OUTPUTS Description Values Defaults
is-pull-request-linked-to-issues Whether the pull request is linked to issues or not. 'True' or 'False' 'False'
linked-issues List of issues that are linked to the pull request. [1, 2, 4, 82, 124] []
pull-request-labels List of labels assigned to this pull request. [bug, enhancement, ..] []

Example workflow:

    - name: Find linked issues
      id: find-linked-issues
      uses: Ismoh-Games/find-linked-issues@v1
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        repository: ${{ github.repository }}
        pull-request-number: ${{ github.event.pull_request.number }}
        pull-request-body: ${{ github.event.pull_request.body }}
        copy-issues-labels: true # optional
        include-closed-issues: true # optional
    
    # Use the output from the `find-linked-issues` step
    - name: Use the output
      run: |
        echo "is-pull-request-linked-to-issues: ${{ steps.find-linked-issues.outputs.is-pull-request-linked-to-issues }}"
        echo "linked-issues: ${{ steps.find-linked-issues.outputs.linked-issues }}"
        echo "pull-request-labels: ${{ steps.find-linked-issues.outputs.pull-request-labels }}"

    - name: Conditional step
      if: ${{ steps.find-linked-issues.outputs.is-pull-request-linked-to-issues == 'True' }}
      run: |
        echo "Pull request is linked to issues"

    - name: Another conditional step
      if: ${{ steps.find-linked-issues.outputs.is-pull-request-linked-to-issues == 'False' }}
      run: |
        exit 1

Important notes

This action will only work on pull request events:

When using pull_request_target the token input needs to be a personal access token (PAT), because of GitHubs security settings.
If you need help with creating a PAT, check out this guide.

Further reading

There is a pattern used to find the linked issues in the pull request body.
To get insights on how this pattern works, check out the regex101.com!
When having problems with the pattern, you can test it out on pythex.org.

Local development

Windows:

pip install virtualenv
virtualenv --python %PYTHON_PATH%\\python.exe venv
.\venv\Scripts\activate
# python.exe -m pip install --upgrade pip
pip install --only-binary=:all: -r requirements.txt
#deactivate