Skip to content

Commit

Permalink
Move changes to existing workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
desertaxle committed Jul 8, 2024
1 parent b46325d commit aca801f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 82 deletions.
60 changes: 32 additions & 28 deletions .github/workflows/label-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,36 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Check for required labels
id: label-check
run: |
LABELS=$(jq -r '.pull_request.labels[].name' "$GITHUB_EVENT_PATH")
REQUIRED_LABELS=("docs" "integrations" "fix" "enhancement" "feature" "maintenance")
LABEL_FOUND=false
for label in "${REQUIRED_LABELS[@]}"; do
if echo "$LABELS" | grep -q "$label"; then
LABEL_FOUND=true
break
fi
done
if [ "$LABEL_FOUND" = false ]; then
echo "##[error]This pull request must have one of the following labels to help with sorting for release notes:"
echo " - docs"
echo " - maintenance"
echo " - deprecation"
echo " - integrations"
echo " - fix"
echo " - enhancement"
echo " - feature"
exit 1
fi
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"

- name: Install yq
run: |
pip install yq
- name: Fail the PR if no required label is found
if: steps.label-check.outputs.LABEL_FOUND == 'false'
run: exit 1
- name: Check for specific labels
id: check-label
run: |
found=false
for required_label in $(yq -r '.changelog.categories[] | select(.title != "Uncategorized") | .labels[]' .github/release.yml); do
for pr_label in $(jq -r '.pull_request.labels[].name' "$GITHUB_EVENT_PATH"); do
if [[ "$required_label" == "$pr_label" ]]; then
found=true
break 2
fi
done
done
echo "label_exists=$found" >> $GITHUB_OUTPUT
- name: Fail if no required labels are found
if: steps.check-label.outputs.label_exists == 'false'
run: |
echo "None of the required labels are applied to the PR."
exit 1
54 changes: 0 additions & 54 deletions .github/workflows/label-checker.yaml

This file was deleted.

0 comments on commit aca801f

Please sign in to comment.