Skip to content

Commit

Permalink
Update PullRequest.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasc-ubc committed Feb 4, 2025
1 parent af43a84 commit a0df97f
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion .github/workflows/PullRequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,29 @@ jobs:
})
const issues = await github.paginate(opts)
const PR_NUMBER = context.payload.pull_request.number;
const REPO_OWNER = context.repo.owner;
const REPO_NAME = context.repo.repo;
// Check if the 'greeted' label is already present
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
owner: REPO_OWNER,
repo: REPO_NAME,
issue_number: PR_NUMBER,
});
const alreadyGreeted = labels.some(label => label.name === 'greeted');
// Don't post the message more than once.
if (alreadyGreeted) {
console.log(`PR #${PR_NUMBER} has already been greeted.`);
return
}
for (const issue of issues) {
if (issue.number === context.issue.number) {
continue
}
if (issue.pull_request) {
console.log(`Creator #${creator} has already been greeted.`);
return // Creator is already a contributor.
}
}
Expand All @@ -49,3 +66,13 @@ jobs:
`
})
// Add the 'greeted' label to mark this PR as greeted
await github.rest.issues.addLabels({
owner: REPO_OWNER,
repo: REPO_NAME,
issue_number: PR_NUMBER,
labels: ['greeted'],
});
console.log(`Welcome message posted for PR #${PR_NUMBER}`);

0 comments on commit a0df97f

Please sign in to comment.