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

Merging contribution from shpingalet007 to remove 'prefixOnly' #6

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 3 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: shanegenschaw/pull-request-comment-trigger@v2.1.0
- uses: shanegenschaw/pull-request-comment-trigger@v2.2.0
id: check
with:
trigger: '@deploy'
Expand All @@ -47,7 +47,7 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: shanegenschaw/pull-request-comment-trigger@v2.1.0
- uses: shanegenschaw/pull-request-comment-trigger@v2.2.0
id: check
with:
trigger: '@deploy **'
Expand All @@ -66,8 +66,7 @@ And if you specify a reaction, you have to provide the `GITHUB_TOKEN` env vbl.

| Input | Required? | Description |
| ----- | --------- | ----------- |
| trigger | Yes | The string to look for in pull-request descriptions and comments. For example "#build/android". |
| prefix_only | No (default 'false') | If 'true', the trigger must match the start of the comment. |
| trigger | Yes | The string to look for in pull-request descriptions and comments. The trigger should be placed at the beginning. For example "#build/android". |
| reaction | No (default '') | If set, the specified emoji "reaction" is put on the comment to indicate that the trigger was detected. For example, "rocket". |
| allow_arguments | No (default 'false') | If 'true', script looks for `**` markers that are considered as comment arguments. |

Expand Down
4 changes: 0 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ inputs:
trigger:
description: 'The string to look for in pull-request descriptions and comments. For example "#build/android"'
required: true
prefix_only:
description: If 'true', the trigger must match the start of the comment.
required: false
default: "false"
allow_arguments:
description: If 'true', the trigger can have arguments. Can be passed via "**".
required: false
Expand Down
9 changes: 2 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15917,26 +15917,21 @@ async function run() {
const { owner, repo } = context.repo;


const prefixOnly = core.getInput("prefix_only") === 'true';
const allowArguments = core.getInput("allow_arguments") === 'true';

let hasTrigger = body.startsWith(trigger);

if (allowArguments) {
let regexRawTrigger = trigger.replace(/\s\*{2}/g, ' [^\\s]+');

if (prefixOnly) {
regexRawTrigger = `^${regexRawTrigger}$`;
} else {
regexRawTrigger = `${regexRawTrigger}$`;
}
regexRawTrigger = `^${regexRawTrigger}$`;

const regexTrigger = new RegExp(regexRawTrigger);

hasTrigger = regexTrigger.test(body);
}

if ((prefixOnly && !hasTrigger) || !hasTrigger) {
if (!hasTrigger) {
core.setOutput("triggered", "false");
return;
}
Expand Down
9 changes: 2 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,21 @@ async function run() {
const { owner, repo } = context.repo;


const prefixOnly = core.getInput("prefix_only") === 'true';
const allowArguments = core.getInput("allow_arguments") === 'true';

let hasTrigger = body.startsWith(trigger);

if (allowArguments) {
let regexRawTrigger = trigger.replace(/\s\*{2}/g, ' [^\\s]+');

if (prefixOnly) {
regexRawTrigger = `^${regexRawTrigger}$`;
} else {
regexRawTrigger = `${regexRawTrigger}$`;
}
regexRawTrigger = `^${regexRawTrigger}$`;

const regexTrigger = new RegExp(regexRawTrigger);

hasTrigger = regexTrigger.test(body);
}

if ((prefixOnly && !hasTrigger) || !hasTrigger) {
if (!hasTrigger) {
core.setOutput("triggered", "false");
return;
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pull-request-comment-trigger",
"version": "2.1.0",
"version": "2.2.0",
"description": "",
"main": "dist/index.js",
"scripts": {
Expand Down