Skip to content

Commit

Permalink
Notify if the action fails
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacroldan committed Jul 11, 2024
1 parent b3dfa25 commit 96a1a25
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

19 changes: 13 additions & 6 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@ import {getPackages} from '@manypkg/get-packages';

const silentOption = {silent: true};

const {payload} = github.context;
const ownerRepo = {
owner: payload.repository.owner.login,
repo: payload.repository.name,
};
const octokit = github.getOctokit(process.env.GITHUB_TOKEN);

try {
if (!process.env.GITHUB_TOKEN) {
throw new Error(
'Please provide the GITHUB_TOKEN to the snapit GitHub action',
);
}

const {payload} = github.context;
if (
!payload.comment ||
!payload.repository ||
Expand All @@ -25,11 +31,6 @@ try {
throw new Error('No comment, repository, or issue found in the payload');
}

const ownerRepo = {
owner: payload.repository.owner.login,
repo: payload.repository.name,
};

const buildScript = core.getInput('build_script');
const isGlobal = core.getInput('global_install') === 'true';
const githubCommentIncludedPackages = core.getInput(
Expand Down Expand Up @@ -260,5 +261,11 @@ try {
});
}
} catch (error) {
// If error, update the original comment with an emoji
await octokit.rest.reactions.createForIssueComment({
...ownerRepo,
comment_id: payload.comment.id,
content: '-1',
});
core.setFailed(error.message);
}

0 comments on commit 96a1a25

Please sign in to comment.