Skip to content

Commit

Permalink
add more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminParisel committed Apr 24, 2024
1 parent 6b4636f commit a19ad3b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions packages/surge-preview-tools/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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');
}

Expand Down
12 changes: 6 additions & 6 deletions packages/surge-preview-tools/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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');
}

Expand Down

0 comments on commit a19ad3b

Please sign in to comment.