Skip to content
Closed
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions .github/actions/bot/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: "Bot"
description: "🤖 beep boop"
runs:
using: "composite"
steps:
- uses: actions/github-script@v7
with:
script: |
const bot = require('./.github/actions/bot/index.js');
await bot(core, github, context);
56 changes: 56 additions & 0 deletions .github/actions/bot/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
async function bot(core, github, context) {
const payload = context.payload;

if (!payload.comment) {
console.log("No comment found");
return;
}

const author = payload.comment.user.login;
const authorized = ["OWNER", "MEMBER"].includes(payload.comment.author_association);
if (!authorized) {
console.log(`Not authorized: ${author}`);
return;
}

const body = payload.comment.body.trim();

// Check for /ci test command
if (body === "/ci test") {
console.log("Dispatching ci-test workflow");

// Get PR details
const pr = await github.rest.pulls.get({
owner: payload.repository.owner.login,
repo: payload.repository.name,
pull_number: payload.issue.number
});

// Reply to the comment
await github.rest.issues.createComment({
owner: payload.repository.owner.login,
repo: payload.repository.name,
issue_number: payload.issue.number,
body: `@${author} I've triggered the e2e testing workflow! 🚀`
});

// Dispatch the workflow
await github.rest.actions.createWorkflowDispatch({
owner: payload.repository.owner.login,
repo: payload.repository.name,
workflow_id: 'ci-test.yaml',
ref: 'main',
inputs: {
pr_number: payload.issue.number.toString(),
git_sha: pr.data.head.sha,
requester: author
}
});
}
}

module.exports = async (core, github, context) => {
await bot(core, github, context).catch((error) => {
core.setFailed(error);
});
}
14 changes: 14 additions & 0 deletions .github/workflows/bot-trigger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Bot
run-name: 🤖 beep boop
on:
issue_comment:
types:
- created
jobs:
bot:
if: ${{ github.event.issue.pull_request }}
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/bot