Skip to content

Added step to calculate amount of labels #4

Added step to calculate amount of labels

Added step to calculate amount of labels #4

name: Check for label on pull request
on:
pull_request:
types: [opened, labeled, unlabeled]
branches:
- main
jobs:
check-lables:
runs-on: ubuntu-latest
steps:
- name: Get PR labels
run: |
PR_LABELS="${{ join(github.event.pull_request.labels.*.name, ',') }}"
echo "PR_LABELS=$PR_LABELS" >> $GITHUB_ENV
echo "Labels fetched: $PR_LABELS"
- name: Calculate number of labels
run: |
LABEL_COUNT=$(echo "$PR_LABELS" | awk -F',' '{print NF}')
echo "LABEL_COUNT=$LABEL_COUNT" >> $GITHUB_ENV
- name: Contains lable
if: ${{ env.LABEL_COUNT == '0' }}
run: |
echo "The pull request needs a lable."
exit 1 #This fails the action
- name: Check if pull request labels combination is okay