Skip to content

Commit cb68a32

Browse files
committed
Build action
1 parent 82984b0 commit cb68a32

File tree

8 files changed

+455
-215
lines changed

8 files changed

+455
-215
lines changed

dist/approver/index.js

Lines changed: 111 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -63625,61 +63625,117 @@ const core = __importStar(__nccwpck_require__(2186));
6362563625
const github = __importStar(__nccwpck_require__(5438));
6362663626
const lib_1 = __nccwpck_require__(6791);
6362763627
const track_1 = __nccwpck_require__(1263);
63628+
const jobID = (0, lib_1.optional)('codeball-job-id');
6362863629
function run() {
6362963630
var _a, _b, _c, _d, _e, _f, _g;
6363063631
return __awaiter(this, void 0, void 0, function* () {
63631-
try {
63632-
const pullRequestURL = (_b = (_a = github.context.payload) === null || _a === void 0 ? void 0 : _a.pull_request) === null || _b === void 0 ? void 0 : _b.html_url;
63633-
if (!pullRequestURL) {
63634-
throw new Error('No pull request URL found');
63635-
}
63636-
const pullRequestNumber = (_d = (_c = github.context.payload) === null || _c === void 0 ? void 0 : _c.pull_request) === null || _d === void 0 ? void 0 : _d.number;
63637-
if (!pullRequestNumber) {
63638-
throw new Error('No pull request number found');
63639-
}
63640-
const commitId = (_e = github.context.payload.pull_request) === null || _e === void 0 ? void 0 : _e.head.sha;
63641-
if (!commitId) {
63642-
throw new Error('No commit ID found');
63643-
}
63644-
const repoOwner = (_f = github.context.payload.repository) === null || _f === void 0 ? void 0 : _f.owner.login;
63645-
if (!repoOwner) {
63646-
throw new Error('No repo owner found');
63647-
}
63648-
const repoName = (_g = github.context.payload.repository) === null || _g === void 0 ? void 0 : _g.name;
63649-
if (!repoName) {
63650-
throw new Error('No repo name found');
63651-
}
63652-
const githubToken = core.getInput('GITHUB_TOKEN');
63653-
if (!githubToken) {
63654-
core.setFailed('No GITHUB_TOKEN found');
63655-
return;
63656-
}
63657-
const jobID = core.getInput('codeball-job-id'); // jobID is not required
63658-
const octokit = new lib_1.Octokit({ auth: githubToken });
63659-
yield octokit.pulls.createReview({
63660-
owner: repoOwner,
63661-
repo: repoName,
63662-
pull_number: pullRequestNumber,
63663-
commit_id: commitId,
63664-
body: 'Codeball: LGTM! :+1:',
63665-
event: 'APPROVE'
63666-
});
63667-
yield (0, track_1.track)(jobID, 'approver');
63668-
}
63669-
catch (error) {
63670-
if (error instanceof Error) {
63671-
if (error.message === 'Resource not accessible by integration') {
63672-
core.error('Codeball Approver failed to access GitHub. Check the "GITHUB_TOKEN Permissions" of this job and make sure that the job has WRITE permissions to Pull Requests.');
63673-
core.error(error);
63674-
}
63675-
else {
63676-
core.setFailed(error.message);
63677-
}
63678-
}
63679-
}
63632+
const pullRequestURL = (_b = (_a = github.context.payload) === null || _a === void 0 ? void 0 : _a.pull_request) === null || _b === void 0 ? void 0 : _b.html_url;
63633+
if (!pullRequestURL)
63634+
throw new Error('No pull request URL found');
63635+
const pullRequestNumber = (_d = (_c = github.context.payload) === null || _c === void 0 ? void 0 : _c.pull_request) === null || _d === void 0 ? void 0 : _d.number;
63636+
if (!pullRequestNumber)
63637+
throw new Error('No pull request number found');
63638+
const commitId = (_e = github.context.payload.pull_request) === null || _e === void 0 ? void 0 : _e.head.sha;
63639+
if (!commitId)
63640+
throw new Error('No commit ID found');
63641+
const repoOwner = (_f = github.context.payload.repository) === null || _f === void 0 ? void 0 : _f.owner.login;
63642+
if (!repoOwner)
63643+
throw new Error('No repo owner found');
63644+
const repoName = (_g = github.context.payload.repository) === null || _g === void 0 ? void 0 : _g.name;
63645+
if (!repoName)
63646+
throw new Error('No repo name found');
63647+
const githubToken = (0, lib_1.required)('GITHUB_TOKEN');
63648+
const octokit = new lib_1.Octokit({ auth: githubToken });
63649+
yield octokit.pulls.createReview({
63650+
owner: repoOwner,
63651+
repo: repoName,
63652+
pull_number: pullRequestNumber,
63653+
commit_id: commitId,
63654+
body: 'Codeball: LGTM! :+1:',
63655+
event: 'APPROVE'
63656+
});
6368063657
});
6368163658
}
63682-
run();
63659+
run()
63660+
.then(() => (0, track_1.track)({ jobID, actionName: 'approver' }))
63661+
.catch(error => {
63662+
if (error instanceof Error) {
63663+
(0, track_1.track)({ jobID, actionName: 'approver', error: error.message });
63664+
if (error.message === 'Resource not accessible by integration') {
63665+
core.setFailed('Codeball Approver failed to access GitHub. Check the "GITHUB_TOKEN Permissions" of this job and make sure that the job has WRITE permissions to Pull Requests.');
63666+
}
63667+
else {
63668+
core.setFailed(error.message);
63669+
}
63670+
}
63671+
});
63672+
63673+
63674+
/***/ }),
63675+
63676+
/***/ 7527:
63677+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
63678+
63679+
"use strict";
63680+
63681+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
63682+
if (k2 === undefined) k2 = k;
63683+
var desc = Object.getOwnPropertyDescriptor(m, k);
63684+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
63685+
desc = { enumerable: true, get: function() { return m[k]; } };
63686+
}
63687+
Object.defineProperty(o, k2, desc);
63688+
}) : (function(o, m, k, k2) {
63689+
if (k2 === undefined) k2 = k;
63690+
o[k2] = m[k];
63691+
}));
63692+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
63693+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
63694+
};
63695+
Object.defineProperty(exports, "__esModule", ({ value: true }));
63696+
__exportStar(__nccwpck_require__(8913), exports);
63697+
63698+
63699+
/***/ }),
63700+
63701+
/***/ 8913:
63702+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
63703+
63704+
"use strict";
63705+
63706+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
63707+
if (k2 === undefined) k2 = k;
63708+
var desc = Object.getOwnPropertyDescriptor(m, k);
63709+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
63710+
desc = { enumerable: true, get: function() { return m[k]; } };
63711+
}
63712+
Object.defineProperty(o, k2, desc);
63713+
}) : (function(o, m, k, k2) {
63714+
if (k2 === undefined) k2 = k;
63715+
o[k2] = m[k];
63716+
}));
63717+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
63718+
Object.defineProperty(o, "default", { enumerable: true, value: v });
63719+
}) : function(o, v) {
63720+
o["default"] = v;
63721+
});
63722+
var __importStar = (this && this.__importStar) || function (mod) {
63723+
if (mod && mod.__esModule) return mod;
63724+
var result = {};
63725+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
63726+
__setModuleDefault(result, mod);
63727+
return result;
63728+
};
63729+
Object.defineProperty(exports, "__esModule", ({ value: true }));
63730+
exports.optional = exports.required = void 0;
63731+
const core = __importStar(__nccwpck_require__(2186));
63732+
const required = (name) => core.getInput(name, { required: true });
63733+
exports.required = required;
63734+
const optional = (name) => {
63735+
const value = core.getInput(name, { required: false });
63736+
return value === '' ? undefined : value;
63737+
};
63738+
exports.optional = optional;
6368363739

6368463740

6368563741
/***/ }),
@@ -63778,6 +63834,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
6377863834
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
6377963835
};
6378063836
Object.defineProperty(exports, "__esModule", ({ value: true }));
63837+
__exportStar(__nccwpck_require__(7527), exports);
6378163838
__exportStar(__nccwpck_require__(6518), exports);
6378263839
__exportStar(__nccwpck_require__(3769), exports);
6378363840

@@ -63898,11 +63955,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
6389863955
Object.defineProperty(exports, "__esModule", ({ value: true }));
6389963956
exports.track = void 0;
6390063957
const api_1 = __nccwpck_require__(9095);
63901-
const track = (jobID, actionName) => __awaiter(void 0, void 0, void 0, function* () {
63958+
const track = ({ jobID, actionName, error }) => __awaiter(void 0, void 0, void 0, function* () {
6390263959
return (0, api_1.post)("/track", {
63903-
job_id: jobID,
63960+
job_id: jobID !== null && jobID !== void 0 ? jobID : null,
6390463961
name: actionName,
63905-
});
63962+
error: error !== null && error !== void 0 ? error : null
63963+
}).catch(error => console.warn(error));
6390663964
});
6390763965
exports.track = track;
6390863966

dist/approver/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/baller/index.js

Lines changed: 96 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -63628,33 +63628,99 @@ const track_1 = __nccwpck_require__(1263);
6362863628
function run() {
6362963629
var _a, _b;
6363063630
return __awaiter(this, void 0, void 0, function* () {
63631-
try {
63632-
const pullRequestURL = (_b = (_a = github.context.payload) === null || _a === void 0 ? void 0 : _a.pull_request) === null || _b === void 0 ? void 0 : _b.html_url;
63633-
if (!pullRequestURL) {
63634-
core.setFailed('No pull request URL found');
63635-
return;
63636-
}
63637-
const githubToken = core.getInput('GITHUB_TOKEN');
63638-
if (!githubToken) {
63639-
core.setFailed('No GITHUB_TOKEN found');
63640-
return;
63641-
}
63642-
core.info(`Found contribution: ${pullRequestURL}`);
63643-
const job = yield (0, lib_1.create)({
63644-
url: pullRequestURL,
63645-
access_token: githubToken
63646-
});
63647-
core.info(`Job created: ${job.id}`);
63648-
core.setOutput('codeball-job-id', job.id);
63649-
yield (0, track_1.track)(job.id, 'baller');
63650-
}
63651-
catch (error) {
63652-
if (error instanceof Error)
63653-
core.setFailed(error.message);
63654-
}
63631+
const pullRequestURL = (_b = (_a = github.context.payload) === null || _a === void 0 ? void 0 : _a.pull_request) === null || _b === void 0 ? void 0 : _b.html_url;
63632+
if (!pullRequestURL)
63633+
throw new Error('No pull request URL found');
63634+
const githubToken = core.getInput('GITHUB_TOKEN');
63635+
if (!githubToken)
63636+
throw new Error('No GitHub token found');
63637+
core.info(`Found contribution: ${pullRequestURL}`);
63638+
const job = yield (0, lib_1.create)({
63639+
url: pullRequestURL,
63640+
access_token: githubToken
63641+
});
63642+
core.info(`Job created: ${job.id}`);
63643+
return { jobId: job.id };
6365563644
});
6365663645
}
63657-
run();
63646+
run()
63647+
.then(({ jobId }) => {
63648+
(0, track_1.track)({ jobID: jobId, actionName: 'baller' });
63649+
core.setOutput('codeball-job-id', jobId);
63650+
})
63651+
.catch(error => {
63652+
(0, track_1.track)({ actionName: 'baller', error: error.message });
63653+
if (error instanceof Error) {
63654+
core.setFailed(error.message);
63655+
}
63656+
});
63657+
63658+
63659+
/***/ }),
63660+
63661+
/***/ 7527:
63662+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
63663+
63664+
"use strict";
63665+
63666+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
63667+
if (k2 === undefined) k2 = k;
63668+
var desc = Object.getOwnPropertyDescriptor(m, k);
63669+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
63670+
desc = { enumerable: true, get: function() { return m[k]; } };
63671+
}
63672+
Object.defineProperty(o, k2, desc);
63673+
}) : (function(o, m, k, k2) {
63674+
if (k2 === undefined) k2 = k;
63675+
o[k2] = m[k];
63676+
}));
63677+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
63678+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
63679+
};
63680+
Object.defineProperty(exports, "__esModule", ({ value: true }));
63681+
__exportStar(__nccwpck_require__(8913), exports);
63682+
63683+
63684+
/***/ }),
63685+
63686+
/***/ 8913:
63687+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
63688+
63689+
"use strict";
63690+
63691+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
63692+
if (k2 === undefined) k2 = k;
63693+
var desc = Object.getOwnPropertyDescriptor(m, k);
63694+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
63695+
desc = { enumerable: true, get: function() { return m[k]; } };
63696+
}
63697+
Object.defineProperty(o, k2, desc);
63698+
}) : (function(o, m, k, k2) {
63699+
if (k2 === undefined) k2 = k;
63700+
o[k2] = m[k];
63701+
}));
63702+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
63703+
Object.defineProperty(o, "default", { enumerable: true, value: v });
63704+
}) : function(o, v) {
63705+
o["default"] = v;
63706+
});
63707+
var __importStar = (this && this.__importStar) || function (mod) {
63708+
if (mod && mod.__esModule) return mod;
63709+
var result = {};
63710+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
63711+
__setModuleDefault(result, mod);
63712+
return result;
63713+
};
63714+
Object.defineProperty(exports, "__esModule", ({ value: true }));
63715+
exports.optional = exports.required = void 0;
63716+
const core = __importStar(__nccwpck_require__(2186));
63717+
const required = (name) => core.getInput(name, { required: true });
63718+
exports.required = required;
63719+
const optional = (name) => {
63720+
const value = core.getInput(name, { required: false });
63721+
return value === '' ? undefined : value;
63722+
};
63723+
exports.optional = optional;
6365863724

6365963725

6366063726
/***/ }),
@@ -63753,6 +63819,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
6375363819
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
6375463820
};
6375563821
Object.defineProperty(exports, "__esModule", ({ value: true }));
63822+
__exportStar(__nccwpck_require__(7527), exports);
6375663823
__exportStar(__nccwpck_require__(6518), exports);
6375763824
__exportStar(__nccwpck_require__(3769), exports);
6375863825

@@ -63873,11 +63940,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
6387363940
Object.defineProperty(exports, "__esModule", ({ value: true }));
6387463941
exports.track = void 0;
6387563942
const api_1 = __nccwpck_require__(9095);
63876-
const track = (jobID, actionName) => __awaiter(void 0, void 0, void 0, function* () {
63943+
const track = ({ jobID, actionName, error }) => __awaiter(void 0, void 0, void 0, function* () {
6387763944
return (0, api_1.post)("/track", {
63878-
job_id: jobID,
63945+
job_id: jobID !== null && jobID !== void 0 ? jobID : null,
6387963946
name: actionName,
63880-
});
63947+
error: error !== null && error !== void 0 ? error : null
63948+
}).catch(error => console.warn(error));
6388163949
});
6388263950
exports.track = track;
6388363951

dist/baller/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)