diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c8bc22c..956d23c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,7 @@ jobs: steps: - name: Check PR labels action step id: check_pr_labels - uses: shioyang/check-pr-labels-on-push-action@v1.0.7 + uses: shioyang/check-pr-labels-on-push-action@v1.0.8 with: github-token: ${{ secrets.GITHUB_TOKEN }} labels: '["enhancement"]' diff --git a/README.md b/README.md index 59acbe2..40fc3fc 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ The result if given labels have be applied to the PR ## Example Usage ``` -uses: shioyang/check-pr-labels-on-push-action@v1.0.7 +uses: shioyang/check-pr-labels-on-push-action@v1.0.8 with: github-token: ${{ secrets.GITHUB_TOKEN }} labels: '["label-1", "label-2"]' @@ -42,7 +42,7 @@ jobs: steps: - name: Check PR labels action step id: check_pr_labels - uses: shioyang/check-pr-labels-on-push-action@v1.0.7 + uses: shioyang/check-pr-labels-on-push-action@v1.0.8 with: github-token: ${{ secrets.GITHUB_TOKEN }} labels: '["enhancement"]' diff --git a/dist/index.js b/dist/index.js index aa45bcc..6c8ec49 100644 --- a/dist/index.js +++ b/dist/index.js @@ -33,32 +33,38 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); const core = __importStar(__nccwpck_require__(2186)); const github = __importStar(__nccwpck_require__(5438)); async function run() { + core.debug("Start"); const token = core.getInput("github-token", { required: true }); const octokit = github.getOctokit(token); const labelNames = await getPullRequestLabelNames(octokit); const labels = getInputLabels(); const result = labels.every((label) => labelNames.findIndex((value) => label === value) >= 0); core.setOutput("result", result); + core.debug("End"); } async function getPullRequestLabelNames(octokit) { 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({ owner, 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 || "") : []; } function getInputLabels() { 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}`); }); diff --git a/package.json b/package.json index d8cedd1..a777535 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "check-pr-labels-on-push-action", - "version": "1.0.7", + "version": "1.0.8", "main": "index.js", "repository": "git@github.com:shioyang/check-pr-labels-on-push-action.git", "author": "Tomohiro (Tomo) SHIOYA",