|
9 | 9 | # Only allow slash commands on pull request (not on issues)
|
10 | 10 | if: ${{ github.event.issue.pull_request }}
|
11 | 11 | runs-on: ubuntu-24.04
|
| 12 | + outputs: |
| 13 | + error-message: ${{ steps.dispatch.outputs.error-message }} |
| 14 | + command: ${{ steps.dispatch.outputs.command }} |
12 | 15 | steps:
|
13 | 16 | - name: Slash Command Dispatch
|
14 | 17 | id: dispatch
|
|
36 | 39 | comment-id: ${{ github.event.comment.id }}
|
37 | 40 | body: |
|
38 | 41 | > Error: ${{ steps.dispatch.outputs.error-message }}
|
| 42 | +
|
| 43 | + unrecognizedSlashCommand: |
| 44 | + needs: slashCommandDispatch |
| 45 | + if: > |
| 46 | + github.event.issue.pull_request && |
| 47 | + startsWith(github.event.comment.body, '/') && |
| 48 | + !needs.slashCommandDispatch.outputs.command && |
| 49 | + !needs.slashCommandDispatch.outputs.error-message |
| 50 | + runs-on: ubuntu-24.04 |
| 51 | + steps: |
| 52 | + - name: Generate help text |
| 53 | + id: help |
| 54 | + run: | |
| 55 | + HELP_TEXT="The following slash commands are available: |
| 56 | +
|
| 57 | + - \`/autofix\` - Corrects any linting or formatting issues |
| 58 | + - \`/test\` - Runs the test suite |
| 59 | + - \`/poetry-lock\` - Re-locks dependencies and updates the poetry.lock file |
| 60 | + - \`/help\` - Shows this help message" |
| 61 | + |
| 62 | + if [[ "${{ github.event.comment.body }}" == "/help" ]]; then |
| 63 | + echo "body=$HELP_TEXT" >> $GITHUB_OUTPUT |
| 64 | + else |
| 65 | + echo "body=It looks like you are trying to enter a slash command. Either the slash command is unrecognized or you don't have access to call it. |
| 66 | +
|
| 67 | + $HELP_TEXT" >> $GITHUB_OUTPUT |
| 68 | + fi |
| 69 | +
|
| 70 | + - name: Post help message |
| 71 | + uses: peter-evans/create-or-update-comment@v4 |
| 72 | + with: |
| 73 | + comment-id: ${{ github.event.comment.id }} |
| 74 | + body: ${{ steps.help.outputs.body }} |
0 commit comments