Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Arguments parsing implementation #34

Open
wants to merge 7 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
18 changes: 17 additions & 1 deletion .github/workflows/example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,20 @@ jobs:
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
- run: 'echo Found it!'
if: steps.check.outputs.triggered == 'true'
if: steps.check.outputs.triggered == 'true'

arguments-rocket:
runs-on: ubuntu-latest
steps:
- uses: khan/pull-request-comment-trigger@master
id: check
with:
trigger: '#deploy on ** environment'
reaction: rocket
allow_arguments: true
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
- run: |
echo 'Found it!'
echo 'Deploy on ${{ fromJson(steps.check.outputs.arguments)[0] }}'
if: steps.check.outputs.triggered == 'true'
24 changes: 22 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,35 @@ jobs:
if: steps.check.outputs.triggered == 'true'
```

You can either pass arguments in your comment, e.g. `@deploy dev`:

```
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: khan/[email protected]
id: check
with:
trigger: '@deploy **'
reaction: rocket
allow_arguments: true
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
- run: 'echo Found it! Deploy on ${{ fromJson(steps.check.outputs.arguments)[0] }}'
if: steps.check.outputs.triggered == 'true'
```

Reaction must be one of the reactions here: https://developer.github.com/v3/reactions/#reaction-types
And if you specify a reaction, you have to provide the `GITHUB_TOKEN` env vbl.

## Inputs

| 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. |


## Outputs
Expand All @@ -51,3 +70,4 @@ And if you specify a reaction, you have to provide the `GITHUB_TOKEN` env vbl.
| ------ | ----------- |
| triggered | 'true' or 'false' depending on if the trigger phrase was found. |
| comment_body | The comment body. |
| arguments | The comment arguments. |
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ inputs:
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
default: "false"
outputs:
triggered:
description: the string 'true' if the trigger was found, otherwise the string 'false'
Expand Down
Loading