Skip to content
Merged
42 changes: 42 additions & 0 deletions .github/workflows/slash-command-dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
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: ${{ github.token }}
permission: write
dispatch-type: workflow
issue-type: both

commands: |
test

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 }}
47 changes: 47 additions & 0 deletions .github/workflows/tests-command.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Test Action

on:
pull_request:
types: [ready_for_review]
workflow_dispatch:
inputs:
# The following 4 inputs are always passed by the Slash Command Dispatch:
repo:
description: Repo Name. Ignored.
type: choice
required: false
default: airbytehq/airbyte-enterprise
options:
- airbytehq/airbyte-enterprise
gitref:
description: Git Ref. Ignored.
required: false
comment-id:
description: Comment ID. Optional.
required: false
pr:
description: PR Number.
type: number
required: false

permissions:
contents: write
pull-requests: write
issues: write

jobs:
run-format-fix:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Run `poe test` [Poe Command Processor]
uses: ./
with:
pr: ${{ github.event.inputs.pr || github.event.pull_request.number }}
comment-id: ${{ github.event.inputs.comment-id }}
github-token: ${{ github.token }}
command: test
29 changes: 19 additions & 10 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,10 @@ runs:
comment-id: ${{ inputs.comment-id }}
issue-number: ${{ inputs.pr }}
body: |
> **Running `poe ${{ steps.resolve-command.outputs.command }}`...**
> ${{ inputs.start-message || format('**Running `poe {0}`...**', steps.resolve-command.outputs.command) }}
>
> [Link to job logs.][1]
> [Link to job logs.](${{ steps.vars.outputs.run-url }})
>
> [1]: ${{ steps.vars.outputs.run-url }}

- name: Checkout PR
if: inputs.pr
Expand Down Expand Up @@ -202,18 +213,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 || format(' 🟦 Poe command `{0}` completed successfully.', steps.resolve-command.outputs.command) }}

- name: Append failure comment
if: failure() && steps.comment-start.outputs.comment-id
Expand All @@ -222,7 +232,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 || format('❌ Poe command `{0}` failed. Please inspect the logs.', steps.resolve-command.outputs.command) }}

# Create a new PR if no PR was provided

Expand All @@ -242,9 +252,8 @@ runs:
It contains the output of the command `${{ steps.resolve-command.outputs.command }}`.
Please review the changes and consider merging them if they are acceptable.

[Link to job logs.][1]
[Link to job logs.](${{ steps.vars.outputs.run-url }})

[1]: ${{ steps.vars.outputs.run-url }}
branch: auto-commit/poe-processor-${{ github.run_id }}
draft: true
commit-user-name: Octavia Squidington III
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"