gh-legacy
Version:
A powerful GitHub CLI tool for automatic repository ownership transfer to trusted beneficiaries after periods of inactivity
77 lines (68 loc) • 3.43 kB
JavaScript
// lib/email.js
const nodemailer = require('nodemailer');
exports.sendEmailNotification = async (to, repo, githubUsername) => {
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: process.env.GMAIL_USER,
pass: process.env.GMAIL_PASS
}
});
const mailOptions = {
from: process.env.GMAIL_USER,
to,
subject: `🚀 Repository Access Granted: ${repo}`,
html: `
<div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto;">
<h2 style="color: #2c3e50;">🎉 Repository Access Granted!</h2>
<div style="background-color: #f8f9fa; padding: 20px; border-radius: 8px; margin: 20px 0;">
<h3 style="color: #27ae60; margin-top: 0;">Repository: ${repo}</h3>
<p><strong>GitHub Username:</strong> ${githubUsername}</p>
<p><strong>Access Type:</strong> Admin permissions granted</p>
</div>
<div style="background-color: #e8f5e8; padding: 15px; border-radius: 8px; margin: 20px 0;">
<h4 style="color: #27ae60; margin-top: 0;">What happened?</h4>
<p>The repository owner was inactive for the specified time period, and you have been granted admin access to the repository.</p>
<ul>
<li>✅ You have been added as an admin collaborator</li>
<li>✅ You can now manage the repository</li>
<li>⚠️ Ownership transfer requires manual action (see below)</li>
</ul>
</div>
<div style="background-color: #fff3cd; padding: 15px; border-radius: 8px; margin: 20px 0;">
<h4 style="color: #856404; margin-top: 0;">🚨 IMPORTANT: Complete Ownership Transfer</h4>
<p>Due to GitHub security restrictions, you need to manually request ownership transfer:</p>
<ol>
<li>Go to the repository: <a href="https://github.com/${repo}" style="color: #007bff;">https://github.com/${repo}</a></li>
<li>Click on "Settings" tab</li>
<li>Scroll down to "Danger Zone"</li>
<li>Click "Transfer ownership"</li>
<li>Enter the repository name to confirm</li>
<li>Click "I understand, transfer this repository"</li>
</ol>
<p><strong>Note:</strong> You can only request transfer if you're an admin. The transfer will be pending until the current owner approves.</p>
</div>
<div style="background-color: #d1ecf1; padding: 15px; border-radius: 8px; margin: 20px 0;">
<h4 style="color: #0c5460; margin-top: 0;">Alternative: Owner Transfer</h4>
<p>If you prefer, the current owner can also transfer ownership to you manually:</p>
<ol>
<li>Ask the current owner to go to repository settings</li>
<li>Scroll to "Danger Zone"</li>
<li>Click "Transfer ownership"</li>
<li>Enter your username: <strong>${githubUsername}</strong></li>
<li>Confirm the transfer</li>
</ol>
</div>
<p style="color: #6c757d; font-size: 14px; margin-top: 30px;">
This is an automated notification from the gh-legacy system.
</p>
</div>
`
};
try {
await transporter.sendMail(mailOptions);
console.log(`📧 Email sent to ${to}`);
} catch (err) {
console.error(`❌ Failed to send email to ${to}:`, err.message);
}
};