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:
5
.github/workflows/pr-review-automation.yml
vendored
5
.github/workflows/pr-review-automation.yml
vendored
@@ -10,6 +10,11 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
pr-review-automation:
|
pr-review-automation:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
# Add permissions for the GITHUB_TOKEN to comment on PRs
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
pull-requests: write
|
||||||
|
issues: write
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,16 @@ const token = process.env.GITHUB_TOKEN;
|
|||||||
const octokit = getOctokit(token);
|
const octokit = getOctokit(token);
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
const pr = context.payload.pull_request;
|
try {
|
||||||
const { owner, repo } = context.repo;
|
const pr = context.payload.pull_request;
|
||||||
const prNumber = pr.number;
|
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({
|
const filesChanged = await octokit.rest.pulls.listFiles({
|
||||||
owner,
|
owner,
|
||||||
@@ -67,6 +74,11 @@ async function run() {
|
|||||||
} else {
|
} else {
|
||||||
console.log("No issues found in this PR.");
|
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) {
|
async function checkForNewApiLinks(owner, repo, pr) {
|
||||||
|
|||||||
Reference in New Issue
Block a user