diff --git a/packages/surge-preview-tools/dist/index.js b/packages/surge-preview-tools/dist/index.js index af78c13..59f29ce 100644 --- a/packages/surge-preview-tools/dist/index.js +++ b/packages/surge-preview-tools/dist/index.js @@ -13473,8 +13473,9 @@ async function getPrNumber(github_context){ payload?.workflow_run?.head_sha; if (payload.number && payload.pull_request) { - _actions_core__WEBPACK_IMPORTED_MODULE_0__.debug('prNumber retrieved from pull_request'); - prNumber = payload.number; + _actions_core__WEBPACK_IMPORTED_MODULE_0__.debug(`prNumber retrieved from pull_request ${payload.number}`); + _actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`Find PR number: ${prNumber}`); + return payload.number; } else { _actions_core__WEBPACK_IMPORTED_MODULE_0__.debug('Not a pull_request, so doing a API search'); // Inspired by https://github.com/orgs/community/discussions/25220#discussioncomment-8697399 @@ -13486,14 +13487,12 @@ async function getPrNumber(github_context){ const result = await octokit.rest.search.issuesAndPullRequests(query); const pr = result.data.items.length > 0 && result.data.items[0]; _actions_core__WEBPACK_IMPORTED_MODULE_0__.debug(`Found related pull_request: ${JSON.stringify(pr, null, 2)}`); - prNumber = pr ? pr.number : undefined; + return pr ? pr.number : undefined; } catch (e) { // As mentioned in https://github.com/orgs/community/discussions/25220#discussioncomment-8971083 // from time to time, you may get rate limit errors given search API seems to use many calls internally. _actions_core__WEBPACK_IMPORTED_MODULE_0__.warning(`Unable to get the PR number with API search: ${e}`); } - _actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`Find PR number: ${prNumber}`); - return prNumber; } } try { @@ -13502,7 +13501,8 @@ try { const {job, payload} = _actions_github__WEBPACK_IMPORTED_MODULE_1__.context; const prNumber= await getPrNumber(_actions_github__WEBPACK_IMPORTED_MODULE_1__.context); - if(!prNumber){ + _actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`Find PR number: ${prNumber}`); + if(prNumber === undefined){ _actions_core__WEBPACK_IMPORTED_MODULE_0__.setFailed('No PR number found'); } diff --git a/packages/surge-preview-tools/src/index.js b/packages/surge-preview-tools/src/index.js index 2517c5f..172d06d 100644 --- a/packages/surge-preview-tools/src/index.js +++ b/packages/surge-preview-tools/src/index.js @@ -17,8 +17,9 @@ async function getPrNumber(github_context){ payload?.workflow_run?.head_sha; if (payload.number && payload.pull_request) { - core.debug('prNumber retrieved from pull_request'); - prNumber = payload.number; + core.debug(`prNumber retrieved from pull_request ${payload.number}`); + core.info(`Find PR number: ${prNumber}`); + return payload.number; } else { core.debug('Not a pull_request, so doing a API search'); // Inspired by https://github.com/orgs/community/discussions/25220#discussioncomment-8697399 @@ -30,14 +31,12 @@ async function getPrNumber(github_context){ const result = await octokit.rest.search.issuesAndPullRequests(query); const pr = result.data.items.length > 0 && result.data.items[0]; core.debug(`Found related pull_request: ${JSON.stringify(pr, null, 2)}`); - prNumber = pr ? pr.number : undefined; + return pr ? pr.number : undefined; } catch (e) { // As mentioned in https://github.com/orgs/community/discussions/25220#discussioncomment-8971083 // from time to time, you may get rate limit errors given search API seems to use many calls internally. core.warning(`Unable to get the PR number with API search: ${e}`); } - core.info(`Find PR number: ${prNumber}`); - return prNumber; } } try { @@ -46,7 +45,8 @@ try { const {job, payload} = github.context; const prNumber= await getPrNumber(github.context); - if(!prNumber){ + core.info(`Find PR number: ${prNumber}`); + if(prNumber === undefined){ core.setFailed('No PR number found'); }