Skip to content

Notify users based on roundup label #552

Notify users based on roundup label

Notify users based on roundup label #552

name: Notify users based on roundup label
on:
issues:
types: [labeled]
schedule:
# Run daily at 9 AM UTC to check for 20-day-old issues
- cron: '0 9 * * *'
env:
RECIPIENTS: '@bph @adamziel @jonathanbossenger @alexapeduzzi @fellyph'
jobs:
# Initial notification when label is applied
initial-notification:
if: github.event_name == 'issues' && contains(github.event.issue.labels.*.name, 'Monthly Roundup')
runs-on: ubuntu-latest
steps:
- name: Notify on Monthly Roundup label
uses: actions/github-script@v7
with:
script: |
const recipients = process.env.RECIPIENTS
const message = `Heads-up ${recipients}: To include your project's **news for developers**, please add the information or a link as a comment to this issue.\n**Deadline 5th of next month.**`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: message
});
# Follow-up notification after 20 days
followup-notification:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
steps:
- name: Send 20-day reminder for Monthly Roundup issue
uses: actions/github-script@v7
with:
script: |
const recipients = process.env.RECIPIENTS;
// Get the single open Monthly Roundup issue (if it exists)
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'Monthly Roundup',
per_page: 1
});
if (issues.data.length === 0) {
console.log('No open Monthly Roundup issues found');
return;
}
const issue = issues.data[0];
const createdDate = new Date(issue.created_at);
const daysSinceCreation = Math.floor((Date.now() - createdDate.getTime()) / (1000 * 60 * 60 * 24));
console.log(`Issue #${issue.number} is ${daysSinceCreation} days old`);
// Only proceed if issue is exactly 20 days old (within 24-hour window)
if (daysSinceCreation < 20 || daysSinceCreation >= 21) {
console.log('Issue not in 20-day window, skipping');
return;
}
// Check if follow-up already sent to avoid duplicates
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number
});
const hasFollowup = comments.data.some(comment =>
comment.body.includes('📢 20-Day Follow-up Reminder')
);
if (hasFollowup) {
console.log('Follow-up already sent, skipping');
return;
}
// Send the follow-up notification
const message = `📢 Reminder ${recipients} The publication deadline is approaching (5th of the month).`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: message
});
console.log(`✅ Sent 20-day follow-up for issue #${issue.number}`);