fix: skip the webhook for non-scheduled, successful runs

This commit is contained in:
A.J. Kaptijn 2025-03-19 15:39:41 +01:00
parent 41e145556f
commit f991aceda2
2 changed files with 8 additions and 2 deletions

3
dist/index.js generated vendored
View file

@ -174,6 +174,7 @@ class TestReporter {
this.onlySummary = core.getInput('only-summary', { required: false }) === 'true'; this.onlySummary = core.getInput('only-summary', { required: false }) === 'true';
this.token = core.getInput('token', { required: true }); this.token = core.getInput('token', { required: true });
this.slackWebhook = core.getInput('slack-url', { required: false }); this.slackWebhook = core.getInput('slack-url', { required: false });
this.githubEvent = core.getInput('github-event', { required: false });
this.resultsEndpoint = core.getInput('test-results-endpoint', { required: false }); this.resultsEndpoint = core.getInput('test-results-endpoint', { required: false });
this.resultsEndpointSecret = core.getInput('test-results-endpoint-secret', { required: false }); this.resultsEndpointSecret = core.getInput('test-results-endpoint-secret', { required: false });
this.context = (0, github_utils_1.getCheckRunContext)(); this.context = (0, github_utils_1.getCheckRunContext)();
@ -408,9 +409,11 @@ class TestReporter {
}); });
} }
}); });
if (this.githubEvent === 'schedule' || failed > 0) {
yield webhook.send(req); yield webhook.send(req);
} }
} }
}
catch (error) { catch (error) {
core.error(`Could not create check to store the results`); core.error(`Could not create check to store the results`);
} }

View file

@ -48,6 +48,7 @@ class TestReporter {
readonly onlySummary = core.getInput('only-summary', {required: false}) === 'true' readonly onlySummary = core.getInput('only-summary', {required: false}) === 'true'
readonly token = core.getInput('token', {required: true}) readonly token = core.getInput('token', {required: true})
readonly slackWebhook = core.getInput('slack-url', {required: false}) readonly slackWebhook = core.getInput('slack-url', {required: false})
readonly githubEvent = core.getInput('github-event', {required: false})
readonly resultsEndpoint = core.getInput('test-results-endpoint', {required: false}) readonly resultsEndpoint = core.getInput('test-results-endpoint', {required: false})
readonly resultsEndpointSecret = core.getInput('test-results-endpoint-secret', {required: false}) readonly resultsEndpointSecret = core.getInput('test-results-endpoint-secret', {required: false})
readonly octokit: InstanceType<typeof GitHub> readonly octokit: InstanceType<typeof GitHub>
@ -357,8 +358,10 @@ class TestReporter {
} }
}) })
if (this.githubEvent === 'schedule' || failed > 0) {
await webhook.send(req) await webhook.send(req)
} }
}
} catch (error) { } catch (error) {
core.error(`Could not create check to store the results`) core.error(`Could not create check to store the results`)
} }