Skip to content

Commit

Permalink
chore: add option for multiple labels
Browse files Browse the repository at this point in the history
  • Loading branch information
Anmol-Baranwal committed Nov 11, 2023
1 parent db6ed60 commit dd87c16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 24 deletions.
16 changes: 0 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,3 @@ jobs:
- uses: ./
with:
gh-token: ${{ secrets.GITHUB_TOKEN }}
# - name: Setup Node.js
# uses: actions/setup-node@v2
# with:
# node-version: 16

# - name: Install Dependencies
# run: npm install

# - name: Compile TypeScript
# run: npx tsc

# - name: Run Custom Action
# run: |
# node dist/index.js
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14 changes: 6 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import * as core from "@actions/core";
import * as github from "@actions/github";

// const core = require("@actions/core");
// const github = require("@actions/github");

async function HandleMultipleIssues() {
console.log("Hello World!");

try {
// const token = process.env.GITHUB_TOKEN;
const token = core.getInput("gh-token");

if (!token) core.debug(token + "");
Expand All @@ -27,7 +23,9 @@ 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") || "up for grabs"; // Set default label
const labelInput = core.getInput("label");
const labels = labelInput ? JSON.parse(labelInput) : ["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;
Expand Down Expand Up @@ -65,8 +63,8 @@ async function HandleMultipleIssues() {
.join(", ");

// Check if label is an array and add multiple labels if needed
if (Array.isArray(label)) {
for (const lbl of label) {
if (Array.isArray(labels) && labels.length > 0) {
for (const lbl of labels) {
await octokit.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
Expand All @@ -80,7 +78,7 @@ async function HandleMultipleIssues() {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumberToLabel,
labels: [label],
labels: [labels[0]],
});
}

Expand Down

0 comments on commit dd87c16

Please sign in to comment.