Skip to content

Commit

Permalink
Build outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
bigdaz committed Jan 2, 2024
1 parent 1235bad commit 8bd674c
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 26 deletions.
40 changes: 28 additions & 12 deletions dist/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -140539,6 +140539,7 @@ exports.generateJobSummary = void 0;
const core = __importStar(__nccwpck_require__(42186));
const github = __importStar(__nccwpck_require__(95438));
const summary_1 = __nccwpck_require__(81327);
const request_error_1 = __nccwpck_require__(10537);
const params = __importStar(__nccwpck_require__(23885));
const cache_reporting_1 = __nccwpck_require__(66674);
function generateJobSummary(buildResults, cacheListener) {
Expand Down Expand Up @@ -140566,27 +140567,42 @@ function generateJobSummary(buildResults, cacheListener) {
exports.generateJobSummary = generateJobSummary;
function addPRComment(jobSummary) {
return __awaiter(this, void 0, void 0, function* () {
try {
const github_token = params.getGithubToken();
const context = github.context;
if (context.payload.pull_request == null) {
core.info('No pull_request trigger: not adding PR comment');
return;
}
const pull_request_number = context.payload.pull_request.number;
core.info(`Adding Job Summary as comment to PR #${pull_request_number}.`);
const prComment = `<h3>Job Summary for gradle-build-action</h3>
const context = github.context;
if (context.payload.pull_request == null) {
core.info('No pull_request trigger: not adding PR comment');
return;
}
const pull_request_number = context.payload.pull_request.number;
core.info(`Adding Job Summary as comment to PR #${pull_request_number}.`);
const prComment = `<h3>Job Summary for gradle-build-action</h3>
<h5>${github.context.workflow} :: <em>${github.context.job}</em></h5>

${jobSummary}`;
const octokit = github.getOctokit(github_token);
const github_token = params.getGithubToken();
const octokit = github.getOctokit(github_token);
try {
yield octokit.rest.issues.createComment(Object.assign(Object.assign({}, context.repo), { issue_number: pull_request_number, body: prComment }));
}
catch (error) {
core.warning(`Failed to generate PR comment: ${String(error)}`);
if (error instanceof request_error_1.RequestError) {
core.warning(buildWarningMessage(error));
}
else {
throw error;
}
}
});
}
function buildWarningMessage(error) {
const mainWarning = `Failed to generate PR comment.\n${String(error)}`;
if (error.message === 'Resource not accessible by integration') {
return `${mainWarning}
Please ensure that the 'pull_request: write' permission is available for the workflow job.
Note that this permission is never available for a workflow triggered from a repository fork.
`;
}
return mainWarning;
}
function renderSummaryTable(results) {
if (results.length === 0) {
return 'No Gradle build results detected.';
Expand Down
2 changes: 1 addition & 1 deletion dist/main/index.js.map

Large diffs are not rendered by default.

40 changes: 28 additions & 12 deletions dist/post/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137860,6 +137860,7 @@ exports.generateJobSummary = void 0;
const core = __importStar(__nccwpck_require__(42186));
const github = __importStar(__nccwpck_require__(95438));
const summary_1 = __nccwpck_require__(81327);
const request_error_1 = __nccwpck_require__(10537);
const params = __importStar(__nccwpck_require__(23885));
const cache_reporting_1 = __nccwpck_require__(66674);
function generateJobSummary(buildResults, cacheListener) {
Expand Down Expand Up @@ -137887,27 +137888,42 @@ function generateJobSummary(buildResults, cacheListener) {
exports.generateJobSummary = generateJobSummary;
function addPRComment(jobSummary) {
return __awaiter(this, void 0, void 0, function* () {
try {
const github_token = params.getGithubToken();
const context = github.context;
if (context.payload.pull_request == null) {
core.info('No pull_request trigger: not adding PR comment');
return;
}
const pull_request_number = context.payload.pull_request.number;
core.info(`Adding Job Summary as comment to PR #${pull_request_number}.`);
const prComment = `<h3>Job Summary for gradle-build-action</h3>
const context = github.context;
if (context.payload.pull_request == null) {
core.info('No pull_request trigger: not adding PR comment');
return;
}
const pull_request_number = context.payload.pull_request.number;
core.info(`Adding Job Summary as comment to PR #${pull_request_number}.`);
const prComment = `<h3>Job Summary for gradle-build-action</h3>
<h5>${github.context.workflow} :: <em>${github.context.job}</em></h5>

${jobSummary}`;
const octokit = github.getOctokit(github_token);
const github_token = params.getGithubToken();
const octokit = github.getOctokit(github_token);
try {
yield octokit.rest.issues.createComment(Object.assign(Object.assign({}, context.repo), { issue_number: pull_request_number, body: prComment }));
}
catch (error) {
core.warning(`Failed to generate PR comment: ${String(error)}`);
if (error instanceof request_error_1.RequestError) {
core.warning(buildWarningMessage(error));
}
else {
throw error;
}
}
});
}
function buildWarningMessage(error) {
const mainWarning = `Failed to generate PR comment.\n${String(error)}`;
if (error.message === 'Resource not accessible by integration') {
return `${mainWarning}
Please ensure that the 'pull_request: write' permission is available for the workflow job.
Note that this permission is never available for a workflow triggered from a repository fork.
`;
}
return mainWarning;
}
function renderSummaryTable(results) {
if (results.length === 0) {
return 'No Gradle build results detected.';
Expand Down
2 changes: 1 addition & 1 deletion dist/post/index.js.map

Large diffs are not rendered by default.

0 comments on commit 8bd674c

Please sign in to comment.