|
| 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 process 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 | + |
| 85 | + |
| 86 | +Now you can start to tweak the command and make it do something useful! |
0 commit comments