Skip to content

Commit 04330aa

Browse files
authored
feat: support custom messages; tests: add slash command dispatch (#13)
1 parent c726ec9 commit 04330aa

File tree

4 files changed

+111
-10
lines changed

4 files changed

+111
-10
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Slash Command Dispatch
2+
on:
3+
issue_comment:
4+
types: [created]
5+
jobs:
6+
slashCommandDispatch:
7+
name: Dispatch
8+
runs-on: ubuntu-24.04
9+
steps:
10+
# Use pre-made action (handles private repo auth):
11+
- name: Get PR Info
12+
if: ${{ github.event.issue.pull_request }}
13+
id: pr-info
14+
uses: cloudposse-github-actions/[email protected]
15+
with:
16+
id: ${{ github.event.issue.number }}
17+
18+
- name: Slash Command Dispatch (Workflow)
19+
id: scd
20+
uses: peter-evans/slash-command-dispatch@v3
21+
with:
22+
token: ${{ github.token }}
23+
permission: write
24+
dispatch-type: workflow
25+
issue-type: both
26+
27+
commands: |
28+
test
29+
30+
static-args: |
31+
repo=${{ fromJSON(steps.pr-info.outputs.json).head.repo.full_name || github.repository }}
32+
gitref=${{ fromJSON(steps.pr-info.outputs.json).head.ref }}
33+
comment-id=${{ github.event.comment.id }}
34+
pr=${{ github.event.issue.pull_request != null && github.event.issue.number || '' }}
35+
36+
- name: Edit comment with error message
37+
if: steps.scd.outputs.error-message
38+
uses: peter-evans/create-or-update-comment@v1
39+
with:
40+
comment-id: ${{ github.event.comment.id }}
41+
body: |
42+
> Error: ${{ steps.scd.outputs.error-message }}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Test Action
2+
3+
on:
4+
pull_request:
5+
types: [ready_for_review]
6+
workflow_dispatch:
7+
inputs:
8+
# The following 4 inputs are always passed by the Slash Command Dispatch:
9+
repo:
10+
description: Repo Name. Ignored.
11+
type: choice
12+
required: false
13+
default: airbytehq/airbyte-enterprise
14+
options:
15+
- airbytehq/airbyte-enterprise
16+
gitref:
17+
description: Git Ref. Ignored.
18+
required: false
19+
comment-id:
20+
description: Comment ID. Optional.
21+
required: false
22+
pr:
23+
description: PR Number.
24+
type: number
25+
required: false
26+
27+
permissions:
28+
contents: write
29+
pull-requests: write
30+
issues: write
31+
32+
jobs:
33+
run-format-fix:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout code
37+
uses: actions/checkout@v4
38+
with:
39+
fetch-depth: 1
40+
41+
- name: Run `poe test` [Poe Command Processor]
42+
uses: ./
43+
with:
44+
pr: ${{ github.event.inputs.pr || github.event.pull_request.number }}
45+
comment-id: ${{ github.event.inputs.comment-id }}
46+
github-token: ${{ github.token }}
47+
command: test

action.yml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ inputs:
2323
description: "Disable auto-commit step"
2424
required: false
2525
default: "false"
26+
start-message:
27+
description: "Message to include in the start comment"
28+
required: false
29+
default: ""
30+
success-message:
31+
description: "Message to include in the success comment"
32+
required: false
33+
default: ""
34+
failure-message:
35+
description: "Message to include in the failure comment"
36+
required: false
37+
default: ""
2638

2739
runs:
2840
using: "composite"
@@ -95,11 +107,10 @@ runs:
95107
comment-id: ${{ inputs.comment-id }}
96108
issue-number: ${{ inputs.pr }}
97109
body: |
98-
> **Running `poe ${{ steps.resolve-command.outputs.command }}`...**
110+
> ${{ inputs.start-message || format('**Running `poe {0}`...**', steps.resolve-command.outputs.command) }}
99111
>
100-
> [Link to job logs.][1]
112+
> [Link to job logs.](${{ steps.vars.outputs.run-url }})
101113
>
102-
> [1]: ${{ steps.vars.outputs.run-url }}
103114
104115
- name: Checkout PR
105116
if: inputs.pr
@@ -202,18 +213,17 @@ runs:
202213
comment-id: ${{ steps.comment-start.outputs.comment-id }}
203214
reactions: hooray
204215
body: >
205-
✅ Poe command `${{ steps.resolve-command.outputs.command }}` completed successfully. (${{ steps.auto-commit.outputs.commit_hash }})
216+
🤖 Auto-commit successful: ${{ steps.auto-commit.outputs.commit_hash }}
206217
207218
- name: Append no-op comment
208219
if: >
209220
steps.comment-start.outputs.comment-id
210-
&& steps.auto-commit.outputs.changes_detected != 'true'
211221
uses: peter-evans/create-or-update-comment@v4
212222
with:
213223
comment-id: ${{ steps.comment-start.outputs.comment-id }}
214224
reactions: "+1"
215-
body: >
216-
🟦 Poe command `${{ steps.resolve-command.outputs.command }}` completed successfully.
225+
body: |
226+
> ${{ inputs.success-message || format(' 🟦 Poe command `{0}` completed successfully.', steps.resolve-command.outputs.command) }}
217227
218228
- name: Append failure comment
219229
if: failure() && steps.comment-start.outputs.comment-id
@@ -222,7 +232,7 @@ runs:
222232
comment-id: ${{ steps.comment-start.outputs.comment-id }}
223233
reactions: confused
224234
body: >
225-
❌ Poe command `${{ steps.resolve-command.outputs.command }}` failed. Please inspect the logs.
235+
${{ inputs.failure-message || format('❌ Poe command `{0}` failed. Please inspect the logs.', steps.resolve-command.outputs.command) }}
226236
227237
# Create a new PR if no PR was provided
228238

@@ -242,9 +252,8 @@ runs:
242252
It contains the output of the command `${{ steps.resolve-command.outputs.command }}`.
243253
Please review the changes and consider merging them if they are acceptable.
244254
245-
[Link to job logs.][1]
255+
[Link to job logs.](${{ steps.vars.outputs.run-url }})
246256
247-
[1]: ${{ steps.vars.outputs.run-url }}
248257
branch: auto-commit/poe-processor-${{ github.run_id }}
249258
draft: true
250259
commit-user-name: Octavia Squidington III

poe_tasks.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[tasks]
2+
test = "echo 'Dummy tests...'"
3+
test-fail = "exit 1"

0 commit comments

Comments
 (0)