Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate improvements by Fondeadora and collaborators #27

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
61 changes: 40 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Verify Linked Issue Action
A GitHub action that verifies your pull request contains a reference to an issue.

A GitHub action that verifies your pull request contains a reference to an issue.

On a PR that does not include a linked issue or reference to an issue in the body, the check should fail and a comment will be added to the PR.

Expand All @@ -8,66 +9,84 @@ On a PR that does not include a linked issue or reference to an issue in the bod
## Installation

### As a part of an existing workflow
``` yaml

```yaml
- name: Verify Linked Issue
uses: hattan/verify-linked-issue-action@v1.1.1
uses: Fondeadora/verify-linked-issue-action@v1.2.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

Pleasure ensure the following types on the pull_request triggers:

```yaml
pull_request:
types: [edited, synchronize, opened, reopened]
pull_request:
types: [edited, synchronize, opened, reopened]
```

### As a separate workflow
* Ensure you have the folder .github/workflows
* In .github/workflows, place the [pr_verify_linked_issue.yml](example/pr_verify_linked_issue.yml) workflow.

- Ensure you have the folder .github/workflows
- In .github/workflows, place the [pr_verify_linked_issue.yml](example/pr_verify_linked_issue.yml) workflow.

### Inputs

(Optional) The action will add the following text to a PR when verification fails.
'Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>'

You can customize this message by providing an optional 'message' input with the string you would like to include as the comment.

```yaml
- name: Verify Linked Issue
uses: hattan/verify-linked-issue-action@v1.1.1
uses: Fondeadora/verify-linked-issue-action@v1.2.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
message: 'Error! This is a custom error'
```
message: "Error! This is a custom error"
```

You can also provide an alternative ACCESS_TOKEN instead of the GITHUB_TOKEN, in case you need access to different repos, for example.

```yaml
- name: Verify Linked Issue
uses: Fondeadora/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACCESS_TOKEN: ${{ secrets.SECRET_NAME }}
with:
message: "Error! This is a custom error"
```

### File Templates

If you want a more complex message, consider using a static template file. (Support for dynamic templates will be coming soon!)

There are two options when using template files:

* Option 1) Default File Path: Add a file to .github called VERIFY_PR_COMMENT_TEMPLATE.md. The content of this file will be used as the fail comment in the PR.
* Option 2) Speciy a filename input with the path to a template file.
- Option 1) Default File Path: Add a file to .github called VERIFY_PR_COMMENT_TEMPLATE.md. The content of this file will be used as the fail comment in the PR.
- Option 2) Speciy a filename input with the path to a template file.

```yaml
- name: Verify Linked Issue
uses: hattan/verify-linked-issue-action@v1.1.1
uses: Fondeadora/verify-linked-issue-action@v1.2.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
filename: 'example/templates/fail_comment.txt'
filename: "example/templates/fail_comment.txt"
```

## Trying it out

* Create a new pull request and take care to not include a linked item or mention an issue.
* The build should fail.
* Edit the PR body and add a reference to a valid issue (e.g. #123 )
- Create a new pull request and take care to not include a linked item or mention an issue.
- The build should fail.
- Edit the PR body and add a reference to a valid issue (e.g. #123 )

![Failed Build log](images/failed1.png "Failed Build log")

## Known Issues
* There must be a space after the issue number (ie "#12 " not "#12".) This is due to the way the RegEx is structured and will be resolved in a future release.

* The Issue reference by # needs to be in the body, we don't currently look in the title. That is a future enhancement.

v1
- There must be a space after the issue number (ie "#12 " not "#12".) This is due to the way the RegEx is structured and will be resolved in a future release.

- The Issue reference by # needs to be in the body, we don't currently look in the title. That is a future enhancement.

v1
16 changes: 9 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
name: 'Verify Linked Issue'
description: 'A GitHub action that verifies a pull request contains a reference to an issue.'
name: "Verify Linked Issue"
description: "A GitHub action that verifies a pull request contains a reference to an issue."
branding:
icon: check-square
color: green
icon: check-square
color: green
inputs:
message:
description: The text to use as the PR comen for when for pull requests with no linked issues.
required: false
filename:
description: The name of the file to use as the comment template for pull requests with no linked issues.
description: The name of the file to use as the comment template for pull requests with no linked issues.
required: false
runs:
using: 'node12'
main: 'src/index.js'
using: "node12"
main: "src/index.js"
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "verify-linked-issue-action",
"version": "1.0.0",
"version": "1.2.1",
"description": "A GitHub action that verifies your pull request contains a reference to an issue.",
"main": "index.js",
"directories": {
"example": "example"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "GITHUB_TOKEN='' node test/index.test.js"
},
"repository": {
"type": "git",
Expand All @@ -21,7 +21,7 @@
},
"homepage": "https://github.com/hattan/verify-linked-issue-action#readme",
"dependencies": {
"@actions/core": "^1.2.4",
"@actions/core": "^1.2.6",
"@actions/github": "^2.2.0",
"actions-toolkit": "^4.0.0"
}
Expand Down
Loading