mirror of
https://github.com/codecov/codecov-action.git
synced 2026-02-07 19:47:25 +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;
|
||||
};
|
||||
|
||||
const getSendNotifications = (): boolean => {
|
||||
return isTrue(
|
||||
core.getInput('send-notifications'),
|
||||
);
|
||||
};
|
||||
|
||||
const getOverrideBranch = (token: string): string => {
|
||||
let overrideBranch = core.getInput('override_branch');
|
||||
if (!overrideBranch && !token && isPullRequestFromFork()) {
|
||||
|
|
@ -476,4 +482,5 @@ export {
|
|||
buildUploadExec,
|
||||
buildSendNotificationsExec,
|
||||
getToken,
|
||||
getSendNotifications,
|
||||
};
|
||||
|
|
|
|||
31
src/index.ts
31
src/index.ts
|
|
@ -8,7 +8,9 @@ import {
|
|||
buildCommitExec,
|
||||
buildGeneralExec,
|
||||
buildReportExec,
|
||||
buildSendNotificationsExec,
|
||||
buildUploadExec,
|
||||
getSendNotifications,
|
||||
} from './buildExec';
|
||||
import {
|
||||
getBaseUrl,
|
||||
|
|
@ -28,6 +30,11 @@ const run = async (): Promise<void> => {
|
|||
try {
|
||||
const {commitExecArgs, commitOptions, commitCommand} = await buildCommitExec();
|
||||
const {reportExecArgs, reportOptions, reportCommand} = await buildReportExec();
|
||||
const {
|
||||
sendNotificationsExecArgs,
|
||||
sendNotificationsOptions,
|
||||
sendNotificationsCommand,
|
||||
} = await buildSendNotificationsExec();
|
||||
const {
|
||||
uploadExecArgs,
|
||||
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(
|
||||
getCommand(
|
||||
filename,
|
||||
|
|
|
|||
Loading…
Reference in a new issue