diff --git a/src/buildExec.ts b/src/buildExec.ts index dfa73b4..5a942a1 100644 --- a/src/buildExec.ts +++ b/src/buildExec.ts @@ -64,6 +64,12 @@ const getToken = async (): Promise => { 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, }; diff --git a/src/index.ts b/src/index.ts index 4a98800..6c424f9 100644 --- a/src/index.ts +++ b/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 => { 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 => { ); }); }; + const sendNotifications = async (): Promise => { + 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,