Improve PR Review Automation with better error handling and permissions (#563)

* Add PR review automation workflow and script

closes #559

* Improve PR review automation with better error handling and permissions
This commit is contained in:
Juan Diaz
2025-07-11 16:04:20 -04:00
committed by GitHub
parent b05ae5288e
commit 274218e3fb
2 changed files with 20 additions and 3 deletions

View File

@@ -10,6 +10,11 @@ on:
jobs:
pr-review-automation:
runs-on: ubuntu-latest
# Add permissions for the GITHUB_TOKEN to comment on PRs
permissions:
contents: read
pull-requests: write
issues: write
steps:
- uses: actions/checkout@v4

View File

@@ -5,10 +5,17 @@ const token = process.env.GITHUB_TOKEN;
const octokit = getOctokit(token);
async function run() {
try {
const pr = context.payload.pull_request;
const { owner, repo } = context.repo;
const prNumber = pr.number;
console.log(`Working with repository: ${owner}/${repo}`);
console.log(`PR number: ${prNumber}`);
console.log(`PR author: ${pr.user.login}`);
console.log(`Head repo: ${pr.head.repo.full_name}`);
console.log(`Base repo: ${pr.base.repo.full_name}`);
const filesChanged = await octokit.rest.pulls.listFiles({
owner,
repo,
@@ -67,6 +74,11 @@ async function run() {
} else {
console.log("No issues found in this PR.");
}
} catch (error) {
console.error("Error in PR review automation:", error);
// Don't exit with error code to avoid failing the entire workflow
// Just log the error and continue
}
}
async function checkForNewApiLinks(owner, repo, pr) {