Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add help response for unrecognized slash commands #264

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/slash_command_dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ jobs:
# Only allow slash commands on pull request (not on issues)
if: ${{ github.event.issue.pull_request }}
runs-on: ubuntu-24.04
outputs:
error-message: ${{ steps.dispatch.outputs.error-message }}
command: ${{ steps.dispatch.outputs.command }}
steps:
- name: Slash Command Dispatch
id: dispatch
Expand Down Expand Up @@ -36,3 +39,36 @@ jobs:
comment-id: ${{ github.event.comment.id }}
body: |
> Error: ${{ steps.dispatch.outputs.error-message }}

unrecognizedSlashCommand:
needs: slashCommandDispatch
if: >
github.event.issue.pull_request &&
startsWith(github.event.comment.body, '/') &&
!needs.slashCommandDispatch.outputs.command &&
!needs.slashCommandDispatch.outputs.error-message
runs-on: ubuntu-24.04
steps:
- name: Generate help text
id: help
run: |
HELP_TEXT="The following slash commands are available:

- \`/autofix\` - Corrects any linting or formatting issues
- \`/test\` - Runs the test suite
- \`/poetry-lock\` - Re-locks dependencies and updates the poetry.lock file
- \`/help\` - Shows this help message"

if [[ "${{ github.event.comment.body }}" == "/help" ]]; then
echo "body=$HELP_TEXT" >> $GITHUB_OUTPUT
else
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.

$HELP_TEXT" >> $GITHUB_OUTPUT
fi

- name: Post help message
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ github.event.comment.id }}
body: ${{ steps.help.outputs.body }}
Loading