diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1e80ff3..fc89429 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,11 +1,11 @@ -name: Close Multiple Issues from Same Author +name: Handle Multiple Issues from Same Author on: issues: types: - reopened - opened workflow_dispatch: - push: { branches: ["master", "main", "testing"] } + push: { branches: ["main", "testing"] } jobs: close-multiple-issues: @@ -14,4 +14,5 @@ jobs: - uses: actions/checkout@v3 - uses: ./ with: + issueNumber: true gh-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/action.yml b/action.yml index a5ce71f..67f9aa5 100644 --- a/action.yml +++ b/action.yml @@ -1,11 +1,11 @@ -name: "Close Multiple Issues from Same Author" +name: "Handle Multiple Issues from Same Author" description: "GitHub Action to handle the current issue if the author has existing open issues." author: "Anmol Baranwal" inputs: label: description: "Label to add to the current issue." required: false - default: "up for grabs" + default: "multiple issues" issueNumber: description: "Include the previous issue number created by the author in the comment." comment: diff --git a/dist/index.js b/dist/index.js index 55556fb..d922bfc 100644 --- a/dist/index.js +++ b/dist/index.js @@ -32,13 +32,10 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", ({ value: true })); const core = __importStar(__nccwpck_require__(2186)); const github = __importStar(__nccwpck_require__(5438)); -// const core = require("@actions/core"); -// const github = require("@actions/github"); async function HandleMultipleIssues() { var _a; console.log("Hello World!"); try { - // const token = process.env.GITHUB_TOKEN; const token = core.getInput("gh-token"); if (!token) core.debug(token + ""); @@ -52,7 +49,8 @@ async function HandleMultipleIssues() { const context = github.context; core.notice("step 1."); // Retrieve custom inputs - const label = core.getInput("label") || "up for grabs"; // Set default label + const label = core.getInput("label") || "multiple issues"; // Set default label + const labelInput = core.getInput("label"); const issueNumber = core.getInput("issueNumber") === "true" || false; // converts to boolean const comment = core.getInput("comment"); const close = core.getInput("close") === "true" || false; diff --git a/package.json b/package.json index 6ea48ed..0637fa9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "close-multiple-issues", + "name": "handle-multiple-issues", "version": "1.0.0", - "description": "to take actions of multiple issues created by same author", + "description": "GitHub Action workflow designed to take actions on multiple issues created by the same author.", "main": "dist/index.js", "scripts": { "test": "npm test", @@ -10,16 +10,16 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/Anmol-Baranwal/close-multiple-issues.git" + "url": "git+https://github.com/Anmol-Baranwal/handle-multiple-issues.git" }, "bugs": { - "url": "https://github.com/Anmol-Baranwal/close-multiple-issues/issues" + "url": "https://github.com/Anmol-Baranwal/handle-multiple-issues/issues" }, - "homepage": "https://github.com/Anmol-Baranwal/close-multiple-issues#readme", + "homepage": "https://github.com/Anmol-Baranwal/handle-multiple-issues#readme", "keywords": [ "action", "github", - "duplicate", + "same author", "issues", "close", "label", @@ -30,7 +30,7 @@ ".": "./dist/index.js" }, "author": "Anmol-Baranwal (https://github.com/Anmol-Baranwal)", - "license": "GPL-3.0-only", + "license": "MIT", "dependencies": { "@actions/core": "^1.10.1", "@actions/github": "^6.0.0", diff --git a/src/index.ts b/src/index.ts index 55bf6c7..7f03d52 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,9 +23,8 @@ async function HandleMultipleIssues() { core.notice("step 1."); // Retrieve custom inputs - // const label = core.getInput("label") || "up for grabs"; // Set default label + const label = core.getInput("label") || "multiple issues"; // Set default label const labelInput = core.getInput("label"); - const labels = labelInput ? labelInput.split(",") : ["up for grabs"]; const issueNumber = core.getInput("issueNumber") === "true" || false; // converts to boolean const comment = core.getInput("comment"); const close = core.getInput("close") === "true" || false; @@ -63,8 +62,8 @@ async function HandleMultipleIssues() { .join(", "); // Check if label is an array and add multiple labels if needed - if (Array.isArray(labels) && labels.length > 0) { - for (const lbl of labels) { + if (Array.isArray(label)) { + for (const lbl of label) { await octokit.rest.issues.addLabels({ owner: context.repo.owner, repo: context.repo.repo, @@ -78,7 +77,7 @@ async function HandleMultipleIssues() { owner: context.repo.owner, repo: context.repo.repo, issue_number: issueNumberToLabel, - labels: [labels[0]], + labels: [label], }); }