Skip to content
Merged
43 changes: 43 additions & 0 deletions .github/workflows/slash-command-dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Slash Command Dispatch
on:
issue_comment:
types: [created]
jobs:
slashCommandDispatch:
name: Dispatch
runs-on: ubuntu-24.04
steps:
# Use pre-made action (handles private repo auth):
- name: Get PR Info
if: ${{ github.event.issue.pull_request }}
id: pr-info
uses: cloudposse-github-actions/[email protected]
with:
id: ${{ github.event.issue.number }}

- name: Slash Command Dispatch (Workflow)
id: scd
uses: peter-evans/slash-command-dispatch@v3
with:
token: ${{ secrets.GH_PAT_MAINTENANCE_OCTAVIA }}
permission: write
dispatch-type: workflow
issue-type: both

commands: |
test
test-fail

static-args: |
repo=${{ fromJSON(steps.pr-info.outputs.json).head.repo.full_name || github.repository }}
gitref=${{ fromJSON(steps.pr-info.outputs.json).head.ref }}
comment-id=${{ github.event.comment.id }}
pr=${{ github.event.issue.pull_request != null && github.event.issue.number || '' }}

- name: Edit comment with error message
if: steps.scd.outputs.error-message
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ github.event.comment.id }}
body: |
> Error: ${{ steps.scd.outputs.error-message }}
27 changes: 18 additions & 9 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ inputs:
description: "Disable auto-commit step"
required: false
default: "false"
start-message:
description: "Message to include in the start comment"
required: false
default: ""
success-message:
description: "Message to include in the success comment"
required: false
default: ""
failure-message:
description: "Message to include in the failure comment"
required: false
default: ""

runs:
using: "composite"
Expand Down Expand Up @@ -95,11 +107,9 @@ runs:
comment-id: ${{ inputs.comment-id }}
issue-number: ${{ inputs.pr }}
body: |
> **Running `poe ${{ steps.resolve-command.outputs.command }}`...**
> ${{ inputs.start-message || ('**Running `poe' + steps.resolve-command.outputs.command + '`...**') }}
>
> [Link to job logs.][1]
>
> [1]: ${{ steps.vars.outputs.run-url }}
> [Link to job logs.](${{ steps.vars.outputs.run-url }})

- name: Checkout PR
if: inputs.pr
Expand Down Expand Up @@ -202,18 +212,17 @@ runs:
comment-id: ${{ steps.comment-start.outputs.comment-id }}
reactions: hooray
body: >
✅ Poe command `${{ steps.resolve-command.outputs.command }}` completed successfully. (${{ steps.auto-commit.outputs.commit_hash }})
🤖 Auto-commit successful: ${{ steps.auto-commit.outputs.commit_hash }}

- name: Append no-op comment
if: >
steps.comment-start.outputs.comment-id
&& steps.auto-commit.outputs.changes_detected != 'true'
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.comment-start.outputs.comment-id }}
reactions: "+1"
body: >
🟦 Poe command `${{ steps.resolve-command.outputs.command }}` completed successfully.
body: |
${{ inputs.success-message || (' 🟦 Poe command `' + steps.resolve-command.outputs.command + '` completed successfully.') }}

- name: Append failure comment
if: failure() && steps.comment-start.outputs.comment-id
Expand All @@ -222,7 +231,7 @@ runs:
comment-id: ${{ steps.comment-start.outputs.comment-id }}
reactions: confused
body: >
❌ Poe command `${{ steps.resolve-command.outputs.command }}` failed. Please inspect the logs.
${{ inputs.failure-message || ('❌ Poe command `' + steps.resolve-command.outputs.command + '` failed. Please inspect the logs.') }}

# Create a new PR if no PR was provided

Expand Down
3 changes: 3 additions & 0 deletions poe_tasks.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[tasks]
test = "echo 'Dummy tests...'"
test-fail = "exit 1"