Skip to content

Commit

Permalink
fix: remove no use label
Browse files Browse the repository at this point in the history
  • Loading branch information
xrkffgg committed Sep 23, 2022
1 parent cb11554 commit a6c6e82
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
13 changes: 10 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11304,7 +11304,7 @@ async function run() {
const filterLabel = core.getInput('filter-label');
if (filterLabel) {
let arr = [];
for await (let no of issues) {
for await (const no of issues) {
const {
data: { labels },
} = await octokit.issues.get({
Expand Down Expand Up @@ -11333,7 +11333,7 @@ async function run() {
return false;
}

for await (let issue of issues) {
for await (const issue of issues) {
if (labels) {
await octokit.issues.addLabels({
owner,
Expand All @@ -11344,7 +11344,14 @@ async function run() {
core.info(`Actions: [add-labels][${issue}][${labels}] success!`);
}
if (removeLabels && removeLabels.length) {
for (const label of removeLabels) {
const issueInfo = await octokit.issues.get({
owner,
repo,
issue_number: issue,
});
const baseLabels = issueInfo.data.labels.map(({ name }) => name);
const removes = baseLabels.filter(name => removeLabels.includes(name));
for (const label of removes) {
await octokit.issues.removeLabel({
owner,
repo,
Expand Down
13 changes: 10 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async function run() {
const filterLabel = core.getInput('filter-label');
if (filterLabel) {
let arr = [];
for await (let no of issues) {
for await (const no of issues) {
const {
data: { labels },
} = await octokit.issues.get({
Expand Down Expand Up @@ -87,7 +87,7 @@ async function run() {
return false;
}

for await (let issue of issues) {
for await (const issue of issues) {
if (labels) {
await octokit.issues.addLabels({
owner,
Expand All @@ -98,7 +98,14 @@ async function run() {
core.info(`Actions: [add-labels][${issue}][${labels}] success!`);
}
if (removeLabels && removeLabels.length) {
for (const label of removeLabels) {
const issueInfo = await octokit.issues.get({
owner,
repo,
issue_number: issue,
});
const baseLabels = issueInfo.data.labels.map(({ name }) => name);
const removes = baseLabels.filter(name => removeLabels.includes(name));
for (const label of removes) {
await octokit.issues.removeLabel({
owner,
repo,
Expand Down

0 comments on commit a6c6e82

Please sign in to comment.