Skip to content

Commit 0d22bdd

Browse files
feat: add help response for unrecognized slash commands (#264)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Aaron <AJ> Steers <[email protected]>
1 parent 5da0a7f commit 0d22bdd

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

.github/workflows/slash_command_dispatch.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ jobs:
99
# Only allow slash commands on pull request (not on issues)
1010
if: ${{ github.event.issue.pull_request }}
1111
runs-on: ubuntu-24.04
12+
outputs:
13+
error-message: ${{ steps.dispatch.outputs.error-message }}
14+
command: ${{ steps.dispatch.outputs.command }}
1215
steps:
1316
- name: Slash Command Dispatch
1417
id: dispatch
@@ -36,3 +39,36 @@ jobs:
3639
comment-id: ${{ github.event.comment.id }}
3740
body: |
3841
> 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

Comments
 (0)