diff --git a/.github/workflows/slash-command-dispatch.yml b/.github/workflows/slash-command-dispatch.yml new file mode 100644 index 0000000..763c2ac --- /dev/null +++ b/.github/workflows/slash-command-dispatch.yml @@ -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/get-pr@v2.0.0 + 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 }} diff --git a/.github/workflows/tests-command.yml b/.github/workflows/tests-command.yml new file mode 100644 index 0000000..5628588 --- /dev/null +++ b/.github/workflows/tests-command.yml @@ -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 diff --git a/action.yml b/action.yml index cc20bfc..e0fa450 100644 --- a/action.yml +++ b/action.yml @@ -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" @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/poe_tasks.toml b/poe_tasks.toml new file mode 100644 index 0000000..e45f383 --- /dev/null +++ b/poe_tasks.toml @@ -0,0 +1,3 @@ +[tasks] +test = "echo 'Dummy tests...'" +test-fail = "exit 1"