diff --git a/src/index.ts b/src/index.ts index b4803cb..920959e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,6 +3,8 @@ import * as github from "@actions/github"; import { GitHub } from "@actions/github/lib/utils"; async function run() { + core.debug("Start"); + const token = core.getInput("github-token", { required: true }); const octokit = github.getOctokit(token); @@ -13,6 +15,8 @@ async function run() { (label) => labelNames.findIndex((value) => label === value) >= 0 ); core.setOutput("result", result); + + core.debug("End"); } async function getPullRequestLabelNames( @@ -21,6 +25,9 @@ async function getPullRequestLabelNames( const owner = github.context.repo.owner; const repo = github.context.repo.repo; const commit_sha = github.context.sha; + core.debug( + `PR context - Owner: ${owner} Repo: ${repo} Commit_SHA: ${commit_sha}` + ); const response = await octokit.rest.repos.listPullRequestsAssociatedWithCommit({ @@ -28,6 +35,7 @@ async function getPullRequestLabelNames( repo, commit_sha, }); + core.debug(`Retrieved commit data: ${response.data}`); const pr = response.data.length > 0 && response.data[0]; return pr ? pr.labels.map((label) => label.name || "") : []; @@ -35,10 +43,14 @@ async function getPullRequestLabelNames( function getInputLabels(): string[] { const raw = core.getInput("labels", { required: true }); + core.debug(`Get input "labels": ${raw}`); + const json = JSON.parse(raw); + core.debug(`Parsed as JSON: ${json}`); + return Array.isArray(json) ? json : []; } run().catch((err) => { - core.setFailed(err.message); + core.setFailed(`Action failed with error: ${err.message}`); });