verify-linked-issue-action
verify-linked-issue-action copied to clipboard
A few improvements
Hi there,
I have played recently with this action and I have found a few things where I could help.
- Improve issue validation using
issue-parserpackage, which now detects cross-repo issues ( full URL ), ie.https://github.com/hattan/verify-linked-issue-action/issues/29as well as shorthand ones,#issue_number - The issue referenced in the PR sidebar ( connected events ) was not working properly since it was returning inside
forEachnot inside the main function, possible connected to https://github.com/hattan/verify-linked-issue-action/issues/22 - Add output for action has_linked_issues which can be used in other steps/jobs.
- Added one args as
quietwhich prevent action for failing, allowing you to use the output in other steps - Added one arg as
no_commentwhich prevent the action from adding the comment.quietargument automatically for this as true.
Let me know if you find those useful.
P.S one example where I used the output is this:
name: Verify PR
on:
pull_request:
types: [ edited, synchronize, opened, reopened ]
jobs:
verify_linked_issue:
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
name: Ensure Pull Request has a linked issue.
steps:
- name: Verify Linked Issue
id: verify_linked_issues
uses: Codeinwp/verify-linked-issue-action@master
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
with:
quiet: 'true'
- name: Find Comment
uses: peter-evans/find-comment@v1
id: find_coomment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'pirate-bot'
body-includes: No Linked Issue found
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v1
if: steps.verify_linked_issues.outputs.has_linked_issues != 'true'
with:
comment-id: ${{ steps.find_coomment.outputs.comment-id }}
token: ${{ secrets.BOT_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body: |
:guardsman: PR Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>
edit-mode: replace
- name: Fail action on no issue found
if: steps.verify_linked_issues.outputs.has_linked_issues == 'false'
run: exit 1;
- name: Delete comment
uses: jungwinter/comment@v1
if: steps.verify_linked_issues.outputs.has_linked_issues == 'true' && steps.find_coomment.outputs.comment-id != ''
with:
type: delete
comment_id: ${{ steps.find_coomment.outputs.comment-id }}
token: ${{ secrets.BOT_TOKEN }}
Thanks for this @selul and @hattan, these features look really helpful! Do you know if there are any plans for a new release with these changes merged soon?
I'm especially interested in detecting the linked issues in the sidebar (#22). It would be really great to have functionality that checks only the sidebar and ignores the comments. This would be so we can check that each PR has a primary linked issue for quality management purposes.
This project looks dead I wonder if we should fork this project and keep it up to date with things like this and ignoring Dependabot PR's etc??