Skip to content

check pr

check pr #1

Workflow file for this run

name: Star Reminder for Contributors
on:
pull_request:
types: [opened]
jobs:
star-reminder:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: read
steps:
- name: Check star status and send reminder
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { owner, repo } = context.repo;
const contributor = context.payload.pull_request.user.login;
const prNumber = context.payload.pull_request.number;
console.log(`Checking star status for contributor: ${contributor}`);
// Use GraphQL to check if user starred the repo
const query = `
query($owner: String!, $repo: String!, $user: String!) {
user(login: $user) {
starredRepositories(first: 100, orderBy: {field: STARRED_AT, direction: DESC}) {
nodes {
nameWithOwner
}
pageInfo {
hasNextPage
}
}
}
}
`;
try {
const result = await github.graphql(query, {
owner: owner,
repo: repo,
user: contributor
});
const repoFullName = `${owner}/${repo}`;
const hasStarred = result.user.starredRepositories.nodes.some(
starredRepo => starredRepo.nameWithOwner === repoFullName
);
console.log(`Has ${contributor} starred ${repoFullName}? ${hasStarred}`);
if (!hasStarred) {
// Check if we've already sent a reminder on this PR
const comments = await github.rest.issues.listComments({
owner: owner,
repo: repo,
issue_number: prNumber
});
const existingReminder = comments.data.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('awesome contributor! 🌟')
);
if (!existingReminder) {
const message = `Dear @${contributor}
awesome contributor! 🌟 We noticed you contributed to #DevDisplay but forgot to star the repo. It's like making an amazing sandwich and forgetting to take a bite!
I think our repo's feeling a little lonely without your ⭐️ Can you help us out? 🤗
> **Star the repo by clicking the ⭐ button at the top of this page!**`;
await github.rest.issues.createComment({
owner: owner,
repo: repo,
issue_number: prNumber,
body: message
});
console.log(`✅ Sent star reminder to ${contributor}`);
} else {
console.log(`ℹ️ Star reminder already sent to ${contributor} on this PR`);
}
} else {
console.log(`⭐ ${contributor} has already starred the repository - no reminder needed!`);
}
} catch (error) {
console.log(`❌ Error checking star status: ${error.message}`);
// If we can't determine star status, we'll skip sending the reminder
// to avoid spamming users who might have already starred
console.log(`⚠️ Skipping reminder due to API error`);
}