https://github.com/mondeja/pr-linked-issues-action
Get which issues will be closed by a pull request.
https://github.com/mondeja/pr-linked-issues-action
Last synced: 4 months ago
JSON representation
Get which issues will be closed by a pull request.
- Host: GitHub
- URL: https://github.com/mondeja/pr-linked-issues-action
- Owner: mondeja
- License: bsd-3-clause
- Created: 2021-02-03T12:18:36.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2025-01-11T18:11:50.000Z (9 months ago)
- Last Synced: 2025-04-15T15:12:04.648Z (6 months ago)
- Language: Shell
- Size: 55.7 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pr-linked-issues-action
[![Tests][tests-image]][tests-link]
This action returns which issues may be be closed by a pull request using
[Github GraphQL v4 API][graphql-api].
![]()
## Documentation
Without specifying inputs, you should run it on `pull_request` or
`pull_request_target` events and the pull request for which linked issues
will be the pull request that triggered the action.In other contexts you can use `repository_owner`, `repository_name` and
`pull_request` inputs to specify a pull request.This action does not provide a way to check if the outputted linked issues are
in other repositories than the repository where the pull request is triggered,
just outputs issue numbers.### Inputs
All are optional.
- #
repository_owner ⇒ Organization or user owner of the repository against
which the pull request with linked issues to retrieve is opened.
- #
repository_name ⇒ Name of the repository against which the pull request
with linked issues to retrieve is opened.
- #
pull_request ⇒ Number of the pull request to retrieve.
- # owners ⇒ Indicates
if you want to retrieve linked issues owners. If `true`, the outputs
[`opener`](#output-opener) and [`others`](#output-others) will be added.
- # add_links_by_content ⇒ Add other links to issues numbers defined in the
body of the pull request. Specify inside a `{issue_number}` placeholder
a content matcher for additional issues that will be linked. Multiple can be
defined separating them by newlines. Keep in mind that the existence of the
issues discovered by this feature is not guaranteed, it just discovers
numbers giving the provided placeholders. If you pass
[`owners` input](#input-owners) as `true`, you'll be able to check if not
exist checking if are contained by [`null` output](#output-null).### Outputs
- # issues ⇒ Linked
issues for the pull request, separated by commas.If [`owners` input](#input-owners) is `true`, the next outputs will be added:
- # opener ⇒ Linked
issues that have been opened by the pull request opener.
- # others ⇒ Linked
issues that haven't been opened by the pull request opener.If `add_links_by_content` feature discovers issues that doesn't exists
[`owners` input](#input-owners) is `true`, their numbers will be added to the
next output:- # null ⇒ Linked
issues that doesn't exists, so they don't have owner.## Examples
### Get linked issues for current pull request
```yaml
name: Get linked issues
on:
pull_request_target:
types:
- opened
- reopened
- editedjobs:
get-linked-issues:
name: Get linked issues
runs-on: ubuntu-latest
steps:
- name: Get issues
id: get-issues
uses: mondeja/pr-linked-issues-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Print linked issue numbers
run: echo ${{ steps.get-issues.outputs.issues }}
```### Check if pull request has linked issues
```yaml
name: Has linked issues
on:
pull_request_target:
types:
- opened
- reopened
- editedjobs:
check-linked-issues:
name: Check if pull request has linked issues
runs-on: ubuntu-latest
steps:
- name: Get issues
id: get-issues
uses: mondeja/pr-linked-issues-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Print has linked issues
id: has-linked-issues
if: join(steps.get-issues.outputs.issues) != ''
run: echo "Has linked issues"
- name: Print has not linked issues
if: steps.has-linked-issues.conclusion == 'skipped'
run: echo "Has not linked issues"
```### Get linked issues for specified pull request
```yaml
name: Get linked issues
on:
workflow_dispatch:jobs:
get-linked-issues:
name: Get linked issues
runs-on: ubuntu-latest
steps:
- name: Get issues
id: get-issues
uses: mondeja/pr-linked-issues-action@v2
with:
repository_owner:
repository_name:
pull_request:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Print linked issue numbers
run: echo ${{ steps.get-issues.outputs.issues }}
```### Check if pull request resolves other users' issues
```yaml
name: Is generous contributor
on:
pull_request_target:
types:
- opened
- reopened
- editedjobs:
check-others-linked-issues:
name: Has linked issues opened by others
runs-on: ubuntu-latest
steps:
- name: Get issues
id: get-issues
uses: mondeja/pr-linked-issues-action@v2
with:
owners: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Print is generous contributor
if: join(steps.get-issues.outputs.others) != ''
run: echo "You are a generous developer!"
```### Output linked issues by pull request body content
```yaml
name: I report linked issues that are not really linked
on:
pull_request_target:
types:
- opened
- reopened
- editedjobs:
check-linked-issues-by-content:
name: Has "linked issues" defined by PR content
runs-on: ubuntu-latest
steps:
- name: Get issues
id: get-issues
uses: mondeja/pr-linked-issues-action@v2
with:
add_links_by_content: |
**Closes**: #{issue_number}
#
# You can add comments that will be ignored
#
:wrench: the problem #{issue_number} like a boss
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Print linked issue numbers
run: echo ${{ steps.get-issues.outputs.issues }}
```### All outputted issues by pull request body content exist
```yaml
name: I report linked issues that are not really linked
on:
pull_request_target:
types:
- opened
- reopened
- editedjobs:
check-linked-issues-by-content:
name: Has "linked issues" defined by PR content
runs-on: ubuntu-latest
steps:
- name: Get issues
id: get-issues
uses: mondeja/pr-linked-issues-action@v2
with:
add_links_by_content: |
**Closes**: #{issue_number}
:wrench: {issue_number}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Linked issues by pull request body content exist
if: join(steps.get-issues.outputs.null) != ''
run: echo "All are existing issues!"
```[support-ref-closed-issues]: https://github.community/t/support-for-discovering-referenced-and-to-be-closed-issues-from-a-pr/14354/4
[graphql-api]: https://docs.github.com/en/graphql
[tests-image]: https://img.shields.io/github/actions/workflow/status/mondeja/pr-linked-issues-action/ci.yml?branch=master&logo=github&label=tests
[tests-link]: https://github.com/mondeja/pr-linked-issues-action/actions?query=workflow%3ACI