Add emoji reaction bot workflow

This commit is contained in:
Alexa Amundson
2025-11-24 16:37:37 -06:00
parent 386dfd51fa
commit 3152ab4339
2 changed files with 74 additions and 0 deletions

29
.github/workflows/emoji-bot.yml vendored Normal file
View File

@@ -0,0 +1,29 @@
name: 🤖 Emoji-Bot Reaction Handler
on:
issue_comment:
types: [created]
reaction:
types: [created]
jobs:
emoji-bot:
runs-on: ubuntu-latest
steps:
- name: 🧬 Checkout Repo
uses: actions/checkout@v3
- name: 🧠 Set up Node
uses: actions/setup-node@v3
with:
node-version: 18
- name: 📦 Install Dependencies
run: npm install
working-directory: ./bot
- name: 🚦 Run Emoji Bot Handler
run: node index.js
working-directory: ./bot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

45
bot/index.js Normal file
View File

@@ -0,0 +1,45 @@
// bot/index.js
console.log("🤖 Emoji Bot Activated");
const event = process.env.GITHUB_EVENT_PATH;
const fs = require("fs");
if (!event || !fs.existsSync(event)) {
console.error("🚫 No GitHub event payload found.");
process.exit(1);
}
const payload = JSON.parse(fs.readFileSync(event, "utf8"));
console.log("📦 Event Payload:", JSON.stringify(payload, null, 2));
const type = payload.action;
const comment = payload.comment?.body || "";
const reaction = payload.reaction?.content || "";
if (reaction) {
console.log(`🧠 Reaction received: ${reaction}`);
switch (reaction) {
case "eyes":
case "✅":
console.log("✅ Mark as Done");
break;
case "x":
case "❌":
console.log("❌ Mark as Blocked");
break;
case "rotating_light":
case "🛟":
console.log("🛟 Escalation triggered");
break;
case "thinking_face":
case "🤔":
console.log("🤔 Needs Review assigned");
break;
default:
console.log("🪞 No mapping for this reaction.");
}
} else {
console.log("💬 Comment ignored — no emoji trigger detected.");
}