Skip to content

Commit

Permalink
fix: treat exceptions if label is not present
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaminyam committed Jan 26, 2023
1 parent c8b1fb3 commit b82ed49
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 30 deletions.
11 changes: 7 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9610,9 +9610,7 @@ async function run() {
if (target === undefined) {
throw new Error("Can't get payload. Check you trigger event");
}
const {
number,
} = target;
const { number } = target;

const token = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput("repo-token", { required: true });
const octokit = (0,_actions_github__WEBPACK_IMPORTED_MODULE_1__.getOctokit)(token);
Expand All @@ -9636,14 +9634,19 @@ async function run() {
}
}`,
});
const closing_issue_numbers = closing_issue_number_request.repository.pullRequest.closingIssuesReferences.edges.map((edge) => edge.node.number);
const closing_issue_numbers = closing_issue_number_request.repository.pullRequest.closingIssuesReferences.edges.map(
(edge) => edge.node.number
);
for (const closing_issue_number of closing_issue_numbers) {
const issue_labels = await octokit.rest.issues.listLabelsOnIssue({
owner: _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.repo.owner,
repo: _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.repo.repo,
issue_number: closing_issue_number,
});
const labels = issue_labels.data.map((label) => label.name);
if (labels.length === 0) {
continue;
}
const result = await octokit.rest.issues.addLabels({
owner: _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.repo.owner,
repo: _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.repo.repo,
Expand Down
44 changes: 22 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ async function run() {
if (target === undefined) {
throw new Error("Can't get payload. Check you trigger event");
}
const {
number,
} = target;
const { number } = target;

const token = core.getInput("repo-token", { required: true });
const octokit = getOctokit(token);
Expand All @@ -33,14 +31,19 @@ async function run() {
}
}`,
});
const closing_issue_numbers = closing_issue_number_request.repository.pullRequest.closingIssuesReferences.edges.map((edge) => edge.node.number);
const closing_issue_numbers = closing_issue_number_request.repository.pullRequest.closingIssuesReferences.edges.map(
(edge) => edge.node.number
);
for (const closing_issue_number of closing_issue_numbers) {
const issue_labels = await octokit.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: closing_issue_number,
});
const labels = issue_labels.data.map((label) => label.name);
if (labels.length === 0) {
continue;
}
const result = await octokit.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
Expand Down

0 comments on commit b82ed49

Please sign in to comment.