From 91b074285b94d7c20f93bc39db6a7967f342c16e Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja Date: Sun, 18 Aug 2024 20:39:27 +0530 Subject: [PATCH] fix: check labels --- .github/workflows/check-for-labels.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/check-for-labels.yml b/.github/workflows/check-for-labels.yml index f40275d21..499bb4cdd 100644 --- a/.github/workflows/check-for-labels.yml +++ b/.github/workflows/check-for-labels.yml @@ -1,8 +1,13 @@ name: Check for Label on: - issues: - types: [labeled] + pull_request_target: + types: + - opened + - edited + - reopened + - ready_for_review + - synchronize jobs: check-label: @@ -14,11 +19,17 @@ jobs: with: script: | const label = 'your-label-name'; - const labels = context.payload.issue.labels.map(l => l.name); - return labels.includes(label); + console.log(`Looking for label: ${label}`); + + const labels = context.payload.pull_request.labels.map(l => l.name); + console.log('Labels on this pull request:', labels); + + const labelExists = labels.includes(label); + console.log(`Does the label "${label}" exist?`, labelExists); + + return labelExists; - name: Set output - id: set_output run: echo "LABEL_EXISTS=${{ steps.check_label.outputs.result }}" >> $GITHUB_ENV - name: Label exists