Skip to content

Commit 34b1050

Browse files
authored
Merge pull request #18 from peter-evans/getting-started
Add getting started guide
2 parents 5e34a7b + 8737406 commit 34b1050

File tree

3 files changed

+94
-3
lines changed

3 files changed

+94
-3
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ In repositories with a lot of activity, the workflow queue will get backed up ve
1515

1616
Dispatching commands to be processed elsewhere keeps the workflow queue moving quickly. It essentially enables parallel processing of workflows.
1717

18-
### Demo and examples
18+
## Demos
1919

2020
The best way to understand how this works is to try it out for yourself.
2121
Check out the following demos.
@@ -24,11 +24,16 @@ Check out the following demos.
2424
- [ChatOps Demo in Pull Requests](https://github.com/peter-evans/slash-command-dispatch/pull/8)
2525
- [Slash command code formatting - Python](https://github.com/peter-evans/slash-command-dispatch/pull/11)
2626

27-
See [examples](docs/examples.md) for command patterns and example workflows.
27+
## Documentation
28+
29+
- [Getting started](docs/getting-started.md)
30+
- [Examples](docs/examples.md)
31+
- [Standard configuration](#standard-configuration)
32+
- [Advanced configuration](docs/advanced-configuration.md)
2833

2934
## Dispatching commands
3035

31-
### Configuration
36+
### Standard configuration
3237

3338
The following workflow should be configured in the repository where commands will be dispatched from. This example will respond to comments containing the slash commands `/deploy`, `/integration-test` and `/create-ticket`.
3439

assets/example-command.png

70.1 KB
Loading

docs/getting-started.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Getting started
2+
3+
Follow this guide to get started with a working `/example` command.
4+
5+
## Command processing setup
6+
7+
1. Create a new repository called, for example, `slash-command-processor`.
8+
This will be the repository that commands are dispatched to for processing.
9+
10+
2. In your new repository, create the following workflow at `.github/workflows/example-command.yml`.
11+
12+
```yml
13+
name: example-command
14+
on:
15+
repository_dispatch:
16+
types: [example-command]
17+
jobs:
18+
example:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Add reaction
22+
uses: peter-evans/create-or-update-comment@v1
23+
with:
24+
token: ${{ secrets.REPO_ACCESS_TOKEN }}
25+
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
26+
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
27+
reaction-type: hooray
28+
```
29+
30+
3. Create a `repo` scoped Personal Access Token (PAT) by following [this guide](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line).
31+
32+
4. Go to your repository `Settings` -> `Secrets` and `Add a new secret`.
33+
34+
**Name**: `REPO_ACCESS_TOKEN`
35+
36+
**Value**: (The PAT created in step 3)
37+
38+
Command processing setup is complete! Now we need to setup command dispatch for our `/example` command.
39+
40+
## Command dispatch setup
41+
42+
1. Choose a repository or create a new repository to dispatch commands from.
43+
This will be the repository where issue and pull request comments will be monitored for slash commands.
44+
45+
In the repository, create the following workflow at `.github/workflows/slash-command-dispatch.yml`.
46+
47+
**Note**: Change `your-github-username/slash-command-processor` to reference your command processor repository created in the [previous section](#command-processing-setup).
48+
49+
```yml
50+
name: Slash Command Dispatch
51+
on:
52+
issue_comment:
53+
types: [created]
54+
jobs:
55+
slashCommandDispatch:
56+
runs-on: ubuntu-latest
57+
steps:
58+
- name: Slash Command Dispatch
59+
uses: peter-evans/slash-command-dispatch@v1
60+
with:
61+
token: ${{ secrets.REPO_ACCESS_TOKEN }}
62+
commands: example
63+
repository: your-github-username/slash-command-processor
64+
```
65+
66+
2. Create a new `repo` scoped [PAT](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line), OR, use the one created at step 3 of the [previous section](#command-processing-setup).
67+
68+
3. Go to your repository `Settings` -> `Secrets` and `Add a new secret`.
69+
70+
**Name**: `REPO_ACCESS_TOKEN`
71+
72+
**Value**: (The PAT created in step 2)
73+
74+
Command dispatch setup is complete! Now let's test our `/example` command.
75+
76+
## Testing the command
77+
78+
1. Create a new GitHub Issue in the repository you chose to dispatch commands from.
79+
80+
2. Add a new comment with the text `/example`.
81+
82+
Once the command completes you should see all three reactions on your comment.
83+
84+
![Example Command](../assets/example-command.png)
85+
86+
Now you can start to tweak the command and make it do something useful!

0 commit comments

Comments
 (0)