Skip to content

Commit

Permalink
Merge pull request #1400 from yogeshojha/hotfix/workflow_cmt
Browse files Browse the repository at this point in the history
Fix comment workflow on fork PRs
  • Loading branch information
yogeshojha authored Aug 31, 2024
2 parents 579f31e + 12fd79b commit efa0922
Showing 1 changed file with 65 additions and 57 deletions.
122 changes: 65 additions & 57 deletions .github/workflows/auto-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
types: [opened]
pull_request:
types: [opened, closed]
pull_request_target:
types: [opened, closed]

permissions:
issues: write
Expand All @@ -22,69 +24,75 @@ jobs:
const { owner, repo } = context.repo;
const author = context.payload.sender.login;
try {
if (context.eventName === 'issues' && context.payload.action === 'opened') {
const issue = await github.rest.issues.get({
owner,
repo,
issue_number: context.issue.number
});
const isFeatureRequest = issue.data.title.toLowerCase().includes('feat');
let commentBody;
if (isFeatureRequest) {
commentBody = `Hey @${author}! 👋 Thanks for your feature request! 💡
We love hearing new ideas from our community. Here's what happens next:
if (context.eventName === 'issues' && context.payload.action === 'opened') {
const issueTitle = context.payload.issue.title.toLowerCase();
let commentBody;
if (issueTitle.includes('feat')) {
commentBody = `Hey @${author}! 🚀 Thanks for this exciting feature idea!
1. 📋 Our team will review your suggestion
2. 💬 We might reach out for more details if needed
3. 🔍 We'll evaluate how it fits with our roadmap
4. 📢 We'll update you on the status
We love seeing fresh concepts that could take reNgine to the next level. 🌟
To help us understand your vision better, could you:
📝 Provide a detailed description of the feature
🎯 Explain the problem it solves or the value it adds
💡 Share any implementation ideas you might have
Your input is invaluable in shaping the future of reNgine. Let's innovate together! 💪`;
} else {
commentBody = `Hey @${author}! 👋 Thanks for flagging this bug! 🐛🔍
Thanks for helping make reNgine even better! 🚀`;
} else {
commentBody = `Hey @${author}! 👋 Thanks for flagging this! 🐛🐞
You're our superhero bug hunter! 🦸‍♂️🦸‍♀️ Before we suit up to squash this bug, could you please:
📚 Double-check our documentation: https://rengine.wiki
🕵️ Make sure it's not a known issue
📝 Provide all the juicy details about this sneaky bug
Once again - thanks for your vigilance! 🛠️🚀`;
}
github.rest.issues.createComment({
issue_number: context.issue.number,
owner,
repo,
body: commentBody
});
} else if ((context.eventName === 'pull_request' || context.eventName === 'pull_request_target') && context.payload.action === 'opened') {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner,
repo,
body: `Woohoo @${author}! 🎉 You've just dropped some hot new code! 🔥
Before we dig in, Let's make sure you have:
Hang tight while we review this! You rock! 🤘`
});
} else if ((context.eventName === 'pull_request' || context.eventName === 'pull_request_target') && context.payload.action === 'closed') {
const isPRMerged = context.payload.pull_request.merged;
let commentBody;
🔍 Gone through the documentation: https://rengine.wiki
🕵️ Make sure it's not a known issue
📝 Provided us all the details related to this bug`;
}
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner,
repo,
body: commentBody
});
} else if (context.eventName === 'pull_request' && context.payload.action === 'opened') {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner,
repo,
body: `Woohoo @${author}! 🎉 You've just dropped some hot new code! 🔥
if (isPRMerged) {
commentBody = `Holy smokes, @${author}! 🤯 You've just made reNgine even more awesome!
Hang tight while we review this! You rock! 🤘`
});
} else if (context.eventName === 'pull_request' && context.payload.action === 'closed') {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner,
repo,
body: `Holy smokes, @${author}! 🤯 You've just made reNgine even more awesome!
Your code is now part of the reNgine hall of fame. 🏆
Keep the cool ideas coming - maybe next time you'll break the internet! 💻💥
Your code is now part of the reNgine hall of fame. 🏆
Keep the cool ideas coming - maybe next time you'll break the internet! 💻💥
Virtual high fives all around! 🙌`;
} else {
commentBody = `Hey @${author}, thanks for your contribution! 🙏
Virtual high fives all around! 🙌`
});
We appreciate the time and effort you put into this PR. Sadly this is not the right fit for reNgine at the moment.
While we couldn't merge it this time, we value your interest in improving reNgine.
Feel free to reach out if you have any questions. Thanks again!`;
}
console.log('Comment created successfully');
} catch (error) {
console.error('Error creating comment:', error);
core.setFailed(`Action failed with error: ${error}`);
github.rest.issues.createComment({
issue_number: context.issue.number,
owner,
repo,
body: commentBody
});
}

0 comments on commit efa0922

Please sign in to comment.