mirror of
https://github.com/actions/publish-action.git
synced 2026-01-16 00:34:12 +08:00
Integrate Slack notifications
This commit is contained in:
16
src/main.ts
16
src/main.ts
@@ -1,6 +1,7 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as github from '@actions/github';
|
||||
import { updateTag, validateIfReleaseIsPublished } from './api-utils';
|
||||
import { context } from '@actions/github';
|
||||
import { updateTag, validateIfReleaseIsPublished, postMessageToSlack } from './api-utils';
|
||||
import { validateSemverVersionFromTag, getMajorTagFromFullTag } from './version-utils';
|
||||
|
||||
async function run(): Promise<void> {
|
||||
@@ -18,9 +19,22 @@ async function run(): Promise<void> {
|
||||
|
||||
core.setOutput('major-tag', majorTag);
|
||||
core.info(`The '${majorTag}' major tag now points to the '${sourceTagName}' tag`);
|
||||
|
||||
const slackMessage = `The ${majorTag} tag has been successfully updated for the ${context.repo.repo} action to include changes from the ${sourceTagName}`;
|
||||
await reportStatusToSlack(slackMessage);
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
|
||||
const slackMessage = `Failed to update a major tag for the ${context.repo.repo} action`;
|
||||
await reportStatusToSlack(slackMessage);
|
||||
}
|
||||
};
|
||||
|
||||
async function reportStatusToSlack(message: string): Promise<void> {
|
||||
const slackWebhook = core.getInput('slack-webhook');
|
||||
if (slackWebhook) {
|
||||
await postMessageToSlack(slackWebhook, message);
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
Reference in New Issue
Block a user