mirror of
https://github.com/codecov/codecov-action.git
synced 2026-02-17 00:11:44 +00:00
add sendNotifications functionality to index
This commit is contained in:
parent
4fc97fc913
commit
5a6c6a10d1
2 changed files with 38 additions and 0 deletions
|
|
@ -64,6 +64,12 @@ const getToken = async (): Promise<string> => {
|
||||||
return token;
|
return token;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getSendNotifications = (): boolean => {
|
||||||
|
return isTrue(
|
||||||
|
core.getInput('send-notifications'),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const getOverrideBranch = (token: string): string => {
|
const getOverrideBranch = (token: string): string => {
|
||||||
let overrideBranch = core.getInput('override_branch');
|
let overrideBranch = core.getInput('override_branch');
|
||||||
if (!overrideBranch && !token && isPullRequestFromFork()) {
|
if (!overrideBranch && !token && isPullRequestFromFork()) {
|
||||||
|
|
@ -476,4 +482,5 @@ export {
|
||||||
buildUploadExec,
|
buildUploadExec,
|
||||||
buildSendNotificationsExec,
|
buildSendNotificationsExec,
|
||||||
getToken,
|
getToken,
|
||||||
|
getSendNotifications,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
31
src/index.ts
31
src/index.ts
|
|
@ -8,7 +8,9 @@ import {
|
||||||
buildCommitExec,
|
buildCommitExec,
|
||||||
buildGeneralExec,
|
buildGeneralExec,
|
||||||
buildReportExec,
|
buildReportExec,
|
||||||
|
buildSendNotificationsExec,
|
||||||
buildUploadExec,
|
buildUploadExec,
|
||||||
|
getSendNotifications,
|
||||||
} from './buildExec';
|
} from './buildExec';
|
||||||
import {
|
import {
|
||||||
getBaseUrl,
|
getBaseUrl,
|
||||||
|
|
@ -28,6 +30,11 @@ const run = async (): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const {commitExecArgs, commitOptions, commitCommand} = await buildCommitExec();
|
const {commitExecArgs, commitOptions, commitCommand} = await buildCommitExec();
|
||||||
const {reportExecArgs, reportOptions, reportCommand} = await buildReportExec();
|
const {reportExecArgs, reportOptions, reportCommand} = await buildReportExec();
|
||||||
|
const {
|
||||||
|
sendNotificationsExecArgs,
|
||||||
|
sendNotificationsOptions,
|
||||||
|
sendNotificationsCommand,
|
||||||
|
} = await buildSendNotificationsExec();
|
||||||
const {
|
const {
|
||||||
uploadExecArgs,
|
uploadExecArgs,
|
||||||
uploadOptions,
|
uploadOptions,
|
||||||
|
|
@ -101,6 +108,30 @@ const run = async (): Promise<void> => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
const sendNotifications = async (): Promise<void> => {
|
||||||
|
await exec.exec(
|
||||||
|
getCommand(filename, args, sendNotificationsCommand).join(' '),
|
||||||
|
sendNotificationsExecArgs,
|
||||||
|
sendNotificationsOptions)
|
||||||
|
.then(async (exitCode) => {
|
||||||
|
if (exitCode == 0) {
|
||||||
|
// notifications sent
|
||||||
|
}
|
||||||
|
}).catch((err) => {
|
||||||
|
setFailure(
|
||||||
|
`Codecov:
|
||||||
|
Failed to send notifications: ${err.message}`,
|
||||||
|
failCi,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
if (getSendNotifications()) {
|
||||||
|
await sendNotifications();
|
||||||
|
// don't perform an upload after sending notifications
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
await exec.exec(
|
await exec.exec(
|
||||||
getCommand(
|
getCommand(
|
||||||
filename,
|
filename,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue