From 5e912baf3d7621b716ffccdbadad580325a02305 Mon Sep 17 00:00:00 2001 From: wataru Date: Mon, 16 Oct 2023 23:51:09 +0900 Subject: [PATCH] add error handling --- badges/coverage.svg | 2 +- dist/index.js | 3 +++ src/main.ts | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/badges/coverage.svg b/badges/coverage.svg index af57a94..ff3ef5c 100644 --- a/badges/coverage.svg +++ b/badges/coverage.svg @@ -1 +1 @@ -Coverage: 87.5%Coverage87.5% \ No newline at end of file +Coverage: 85.29%Coverage85.29% \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 854cb5d..7616656 100644 --- a/dist/index.js +++ b/dist/index.js @@ -33249,6 +33249,9 @@ async function run() { Authorization: `token ${GITHUB_TOKEN}` } }); + if (response.data.length === 0) { + core.setFailed('There are no reviews for this pull request yet. Or the url is incorrect.'); + } const approvedReviews = response.data.filter((review) => review.state === 'APPROVED'); const teamApprovalStatus = await Promise.all(conditions.map(async (c) => { const res = await axios_1.default.get(`https://api.github.com/orgs/${owner}/teams/${c.team}/members`, { diff --git a/src/main.ts b/src/main.ts index 37d5ecf..ca567e5 100644 --- a/src/main.ts +++ b/src/main.ts @@ -41,6 +41,12 @@ export async function run(): Promise { } ) + if (response.data.length === 0) { + core.setFailed( + 'There are no reviews for this pull request yet. Or the url is incorrect.' + ) + } + const approvedReviews = response.data.filter( (review: Review) => review.state === 'APPROVED' )