Skip to content
This repository was archived by the owner on Jul 31, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ jobs:
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

- name: Echo output
- name: Echo output in general
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 }}"
Expand All @@ -43,12 +44,14 @@ jobs:
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: Echo output when failure and exit
if: ${{ steps.find-linked-issues.outputs.is-pull-request-linked-to-issues == 'False' }}
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 }}"
exit 1

lint-workflow:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ You can also do this [manually](https://docs.github.com/en/issues/tracking-your-
| `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]` | `[]` |
Expand All @@ -37,6 +38,7 @@ Example workflow:
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
Expand Down
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ inputs:
description: Copy the labels of the linked issues to the pull request. (optional)
required: false
default: 'false'

include-closed-issues:
description: Includes closed issues, when searching for linked issues. (optional)
required: false
default: 'false'

outputs:
is-pull-request-linked-to-issues:
description: Whether the pull request is linked to issues or not.
Expand Down
12 changes: 11 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ def main():
except KeyError:
copy_issues_labels = False

try:
include_closed_issues = os.environ['INPUT_INCLUDE-CLOSED-ISSUES']
except KeyError:
include_closed_issues = False

if include_closed_issues:
is_open = "is:open"
else:
is_open = ""

print("Environment variables fetched successfully")

""" Get pull request """
Expand Down Expand Up @@ -69,7 +79,7 @@ def main():
""" Find issues with GitHub API """
print("Fetching issues...")
url = "https://api.github.com/search/issues?q=" \
+ f"repo:{repository} is:issue is:open linked:pr pr:{pull_request_number} " \
+ f"repo:{repository} is:issue {is_open} linked:pr pr:{pull_request_number} " \
+ " ".join(str(i) for i in issue_numbers)
print(f"Request url: {url}")
headers = {
Expand Down