| 1 |
name: Validate Pull Request |
| 2 |
on: |
| 3 |
pull_request: |
| 4 |
types: |
| 5 |
- opened |
| 6 |
- reopened |
| 7 |
- synchronize |
| 8 |
- labeled |
| 9 |
- unlabeled |
| 10 |
- edited |
| 11 |
|
| 12 |
permissions: {} |
| 13 |
|
| 14 |
jobs: |
| 15 |
required-labels-missing: |
| 16 |
name: required labels missing |
| 17 |
runs-on: ubuntu-latest |
| 18 |
permissions: |
| 19 |
contents: read |
| 20 |
steps: |
| 21 |
- name: check |
| 22 |
if: >- |
| 23 |
!contains(github.event.pull_request.labels.*.name, '💥 breaking-change') |
| 24 |
&& !contains(github.event.pull_request.labels.*.name, '✨ enhancement') |
| 25 |
&& !contains(github.event.pull_request.labels.*.name, '🐞 bug') |
| 26 |
&& !contains(github.event.pull_request.labels.*.name, '📖 docs') |
| 27 |
&& !contains(github.event.pull_request.labels.*.name, 'chore') |
| 28 |
&& !contains(github.event.pull_request.labels.*.name, '🛠️ dependencies') |
| 29 |
run: >- |
| 30 |
echo One of the following labels is missing on this PR: |
| 31 |
breaking-change |
| 32 |
enhancement |
| 33 |
bug |
| 34 |
docs |
| 35 |
chore |
| 36 |
&& exit 1 |
| 37 |
validate-title: |
| 38 |
name: check title prefix |
| 39 |
runs-on: ubuntu-latest |
| 40 |
steps: |
| 41 |
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 42 |
with: |
| 43 |
persist-credentials: 'false' |
| 44 |
- name: check |
| 45 |
run: | |
| 46 |
PR_TITLE_PREFIX=$(echo "$PR_TITLE" | cut -d':' -f1) |
| 47 |
if [[ "$PR_TITLE_PREFIX" == "fix"* ]] || [[ "$PR_TITLE_PREFIX" == "feat"* ]] || [[ "$PR_TITLE_PREFIX" == "docs"* ]] || [[ "$PR_TITLE_PREFIX" == "chore"* ]]; then |
| 48 |
exit 0 |
| 49 |
fi |
| 50 |
|
| 51 |
echo "PR title must start with feat, fix, docs or chore" |
| 52 |
exit 1 |
| 53 |
env: |
| 54 |
PR_TITLE: ${{ github.event.pull_request.title }} |