Skip to content

Commit

Permalink
add version label check for marge request (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
KirisameMarisa authored Jan 6, 2024
1 parent 59d7b4f commit 0361f6e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/version-label-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Restrict Merge Without Version Label

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
check_version_label:
runs-on: ubuntu-latest

steps:
- name: Check if version label is assigned
run: |
PR_NUMBER=$(jq -r ".pull_request.number" "$GITHUB_EVENT_PATH")
LABELS=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/labels" \
| jq -r '.[].name')
if [[ ! "$LABELS" =~ ^(minor|major|patch)$ ]]; then
echo "Error: A version label (minor, major, or patch) is required for merging this PR."
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 0361f6e

Please sign in to comment.