From 22bb392c046797f43121909d3ce9bae610a6e53c Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja Date: Sun, 18 Aug 2024 17:44:55 +0530 Subject: [PATCH] fix: check labels --- .github/workflows/check-for-labels.yml | 30 ++++++++++++++++++++++ .github/workflows/pr-title-spell-check.yml | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/check-for-labels.yml diff --git a/.github/workflows/check-for-labels.yml b/.github/workflows/check-for-labels.yml new file mode 100644 index 000000000..f40275d21 --- /dev/null +++ b/.github/workflows/check-for-labels.yml @@ -0,0 +1,30 @@ +name: Check for Label + +on: + issues: + types: [labeled] + +jobs: + check-label: + runs-on: ubuntu-latest + steps: + - name: Check if label exists + id: check_label + uses: actions/github-script@v6 + with: + script: | + const label = 'your-label-name'; + const labels = context.payload.issue.labels.map(l => l.name); + return labels.includes(label); + + - name: Set output + id: set_output + run: echo "LABEL_EXISTS=${{ steps.check_label.outputs.result }}" >> $GITHUB_ENV + + - name: Label exists + if: env.LABEL_EXISTS == 'true' + run: echo "Label exists." + + - name: Label does not exist + if: env.LABEL_EXISTS == 'false' + run: echo "Label does not exist." diff --git a/.github/workflows/pr-title-spell-check.yml b/.github/workflows/pr-title-spell-check.yml index f62979b4f..96761b2b3 100644 --- a/.github/workflows/pr-title-spell-check.yml +++ b/.github/workflows/pr-title-spell-check.yml @@ -37,4 +37,4 @@ jobs: -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/assignees \ - -d '{"assignees":["${{ github.event.pull_request.user.login }}"]}' \ No newline at end of file + -d '{"assignees":["${{ github.event.pull_request.user.login }}"]}'