Skip to content

Commit

Permalink
Refactor index.ts to use named imports from @actions/core
Browse files Browse the repository at this point in the history
  • Loading branch information
goldsrc committed Mar 4, 2024
1 parent a4c744b commit 641ecb2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
8 changes: 4 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30914,16 +30914,16 @@ __nccwpck_require__.r(__webpack_exports__);
try {
const githubToken = process.env["GITHUB_TOKEN"];
if (!githubToken) {
_actions_core__WEBPACK_IMPORTED_MODULE_0___default().setFailed("GITHUB_TOKEN does not exist.");
(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.setFailed)("GITHUB_TOKEN does not exist.");
return;
}
const octokit = (0,_actions_github__WEBPACK_IMPORTED_MODULE_1__.getOctokit)(githubToken);
const { owner, repo } = _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.repo;
const labels = _actions_core__WEBPACK_IMPORTED_MODULE_0___default().getInput("labels")
const labels = (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)("labels")
.split("\n")
.filter((x) => x !== "");
const issueNumber = _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.payload.number;
_actions_core__WEBPACK_IMPORTED_MODULE_0___default().info(`Add labels: ${labels} to ${owner}/${repo}#${issueNumber}`);
(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.info)(`Add labels: ${labels} to ${owner}/${repo}#${issueNumber}`);
await octokit.rest.issues.addLabels({
owner,
repo,
Expand All @@ -30932,7 +30932,7 @@ __nccwpck_require__.r(__webpack_exports__);
});
}
catch (error) {
_actions_core__WEBPACK_IMPORTED_MODULE_0___default().setFailed(error.message);
(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.setFailed)(error.message);
}
})();

Expand Down
11 changes: 5 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
import core from "@actions/core";
import { setFailed, info, getInput } from "@actions/core";
import { getOctokit, context } from "@actions/github";

(async () => {
try {
const githubToken = process.env["GITHUB_TOKEN"];
if (!githubToken) {
core.setFailed("GITHUB_TOKEN does not exist.");
setFailed("GITHUB_TOKEN does not exist.");
return;
}

const octokit = getOctokit(githubToken);
const { owner, repo } = context.repo;

const labels = core
.getInput("labels")
const labels = getInput("labels")
.split("\n")
.filter((x) => x !== "");

const issueNumber = context.payload.number;

core.info(`Add labels: ${labels} to ${owner}/${repo}#${issueNumber}`);
info(`Add labels: ${labels} to ${owner}/${repo}#${issueNumber}`);

await octokit.rest.issues.addLabels({
owner,
Expand All @@ -28,6 +27,6 @@ import { getOctokit, context } from "@actions/github";
labels,
});
} catch (error) {
core.setFailed(error.message);
setFailed(error.message);
}
})();

0 comments on commit 641ecb2

Please sign in to comment.