Skip to content

Commit 46cb860

Browse files
committed
Update README
1 parent 1145934 commit 46cb860

File tree

1 file changed

+53
-26
lines changed

1 file changed

+53
-26
lines changed

README.md

Lines changed: 53 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Dispatching commands to be processed elsewhere keeps the workflow queue moving q
2828

2929

3030

31-
## Usage
31+
## Dispatching commands
3232

3333
### Basic configuration
3434

@@ -50,31 +50,19 @@ jobs:
5050
5151
### Action inputs
5252
53-
| Name | Description | Default |
54-
| --- | --- | --- |
55-
| `token` | (**required**) A `repo` scoped [PAT](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line). | |
56-
| `reaction-token` | `GITHUB_TOKEN` or a `repo` scoped [PAT](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line). | |
57-
| `reactions` | Add reactions. :eyes: = seen, :rocket: = dispatched | `true` |
58-
| `commands` | (**required**) A comma separated list of commands to dispatch. | |
59-
| `permission` | The repository permission level required by the user to dispatch commands. (`none`, `read`, `write`, `admin`) | `write` |
60-
| `issue-type` | The issue type required for commands. (`issue`, `pull-request`, `both`) | `both` |
61-
| `allow-edits` | Allow edited comments to trigger command dispatches. | `false` |
62-
| `repository` | The full name of the repository to send the dispatch events. | Current repository |
63-
| `event-type-suffix` | The repository dispatch event type suffix for the commands. | `-command` |
64-
| `config` | JSON configuration for commands. | |
65-
| `config-from-file` | JSON configuration from a file for commands. | |
66-
67-
### Handling dispatched commands
68-
69-
Repository dispatch events have a `type` to distinguish between events. The `type` set by the action is a combination of the slash command and `event-type-suffix`. The `event-type-suffix` input defaults to `-command`.
70-
71-
For example, if your slash command is `integration-test`, the event type will be `integration-test-command`.
72-
73-
```yml
74-
on:
75-
repository_dispatch:
76-
types: [integration-test-command]
77-
```
53+
| Input | JSON Property | Description | Default |
54+
| --- | --- | --- | --- |
55+
| `token` | | (**required**) A `repo` scoped [PAT](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line). | |
56+
| `reaction-token` | | `GITHUB_TOKEN` or a `repo` scoped [PAT](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line). | |
57+
| `reactions` | | Add reactions. :eyes: = seen, :rocket: = dispatched | `true` |
58+
| `commands` | `command` | (**required**) A comma separated list of commands to dispatch. | |
59+
| `permission` | `permission` | The repository permission level required by the user to dispatch commands. (`none`, `read`, `write`, `admin`) | `write` |
60+
| `issue-type` | `issue_type` | The issue type required for commands. (`issue`, `pull-request`, `both`) | `both` |
61+
| `allow-edits` | `allow_edits` | Allow edited comments to trigger command dispatches. | `false` |
62+
| `repository` | `repository` | The full name of the repository to send the dispatch events. | Current repository |
63+
| `event-type-suffix` | `event_type_suffix` | The repository dispatch event type suffix for the commands. | `-command` |
64+
| `config` | | JSON configuration for commands. See [Advanced configuration](#advanced-configuration) | |
65+
| `config-from-file` | | JSON configuration from a file for commands. See [Advanced configuration](#advanced-configuration) | |
7866

7967
### What is the reaction-token?
8068

@@ -156,6 +144,45 @@ jobs:
156144
config-from-file: .github/slash-command-dispatch.json
157145
```
158146

147+
## Handling dispatched commands
148+
149+
### Event types
150+
151+
Repository dispatch events have a `type` to distinguish between events. The `type` set by the action is a combination of the slash command and `event-type-suffix`. The `event-type-suffix` input defaults to `-command`.
152+
153+
For example, if your slash command is `integration-test`, the event type will be `integration-test-command`.
154+
155+
```yml
156+
on:
157+
repository_dispatch:
158+
types: [integration-test-command]
159+
```
160+
161+
### Accessing command arguments
162+
163+
```yml
164+
- name: Output command and arguments
165+
run: |
166+
echo ${{ github.event.client_payload.slash_command.command }}
167+
echo ${{ github.event.client_payload.slash_command.args }}
168+
echo ${{ github.event.client_payload.slash_command.arg1 }}
169+
echo ${{ github.event.client_payload.slash_command.arg2 }}
170+
echo ${{ github.event.client_payload.slash_command.arg3 }}
171+
# etc.
172+
```
173+
174+
### Reacting to the comment on completion
175+
176+
```yml
177+
- name: Add reaction
178+
uses: peter-evans/create-or-update-comment@v1
179+
with:
180+
token: ${{ secrets.REPO_ACCESS_TOKEN }}
181+
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
182+
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
183+
reaction-type: hooray
184+
```
185+
159186
## License
160187

161188
[MIT](LICENSE)

0 commit comments

Comments
 (0)