Skip to content

Commit a754f6c

Browse files
authored
Merge pull request #82 from redhat-et/gha-fix
fix owner notification permission issue
2 parents aef795d + b707735 commit a754f6c

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

.github/workflows/owner-notification.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ jobs:
1010
permissions:
1111
contents: read
1212
pull-requests: write
13+
issues: write
1314

1415
steps:
1516
- name: Checkout code
@@ -91,9 +92,34 @@ jobs:
9192
return;
9293
}
9394
95+
// Collect all unique owners for assignment
96+
const allOwners = new Set();
97+
for (const [, info] of ownerMap) {
98+
for (const owner of info.owners) {
99+
// Remove @ prefix for API call
100+
allOwners.add(owner.replace('@', ''));
101+
}
102+
}
103+
104+
// Assign owners to the PR
105+
if (allOwners.size > 0) {
106+
try {
107+
await github.rest.issues.addAssignees({
108+
owner: context.repo.owner,
109+
repo: context.repo.repo,
110+
issue_number: context.issue.number,
111+
assignees: Array.from(allOwners)
112+
});
113+
console.log(`Assigned PR to: ${Array.from(allOwners).join(', ')}`);
114+
} catch (error) {
115+
console.log(`Failed to assign PR: ${error.message}`);
116+
// Continue with comment creation even if assignment fails
117+
}
118+
}
119+
94120
// Create comment content
95121
let commentBody = '## 👥 Owner Notification\n\n';
96-
commentBody += 'The following owners have been identified for the changed files in this PR:\n\n';
122+
commentBody += 'The following owners have been identified for the changed files in this PR and have been automatically assigned:\n\n';
97123
98124
for (const [dirPath, info] of ownerMap) {
99125
commentBody += `### 📁 \`${dirPath === '.' ? 'Root Directory' : dirPath}\`\n`;

0 commit comments

Comments
 (0)