Skip to content

Inline single-use snippets and remove unused snippet files #83

Inline single-use snippets and remove unused snippet files

Inline single-use snippets and remove unused snippet files #83

name: Check Devin AI PR Assignee
on:
pull_request:
types: [opened, reopened]
permissions:
pull-requests: write
jobs:
check-assignee:
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.user.login == 'devin-ai-integration[bot]' }}
steps:
- name: Auto-assign requester from PR description
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const pr = context.payload.pull_request;
const owner = context.repo.owner;
const repo = context.repo.repo;
const prNumber = pr.number;
// Check if assignees already exist
if (pr.assignees && pr.assignees.length > 0) {
console.log(`PR has ${pr.assignees.length} assignee(s), no action needed`);
return;
}
// Email to GitHub username mapping for fern-api org members
const emailToUsername = {
'[email protected]': 'chdeskur',
'[email protected]': 'dannysheridan',
'[email protected]': 'dsinghvi',
'[email protected]': 'alecharmon',
'[email protected]': 'armando-fern',
'[email protected]': 'ryan-fern',
'[email protected]': 'sahil485',
'[email protected]': 'jon-fern',
'[email protected]': 'patrickthornton',
'[email protected]': 'mattblank11',
'[email protected]': 'coltondotio',
'[email protected]': 'kennyderek',
};
// Parse "Requested by:" from PR body - look for the line at the end that starts with "Requested by:"
// Use multiline matching to find the line that starts with "Requested by:" (not example text in the description)
const body = pr.body || '';
const requestedByMatch = body.match(/^Requested by:.*?\(([^)]+@[^)]+)\)/im);
if (!requestedByMatch) {
console.log('Could not find "Requested by:" in PR description');
return;
}
const email = requestedByMatch[1].toLowerCase();
const username = emailToUsername[email];
if (!username) {
console.log(`No GitHub username mapping found for email: ${email}`);
// Post a comment asking for manual assignment
await github.rest.issues.createComment({
owner,
repo,
issue_number: prNumber,
body: `**Assignee Required**\n\nThis PR was opened by Devin AI but the requester's email (${email}) is not in the username mapping. Please add an assignee manually.`
});
return;
}
// Add the assignee
try {
await github.rest.issues.addAssignees({
owner,
repo,
issue_number: prNumber,
assignees: [username]
});
console.log(`Successfully assigned ${username} to PR #${prNumber}`);
} catch (error) {
console.log(`Failed to assign ${username}: ${error.message}`);
await github.rest.issues.createComment({
owner,
repo,
issue_number: prNumber,
body: `**Assignee Required**\n\nFailed to auto-assign ${username}. Please add an assignee manually.`
});
}