forked from tailcallhq/tailcall
-
Notifications
You must be signed in to change notification settings - Fork 1
46 lines (41 loc) · 1.51 KB
/
pr-convention.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
name: PR Title Validation
on:
pull_request:
types: [opened, edited, synchronize, reopened]
jobs:
title-check:
runs-on: ubuntu-latest
outputs:
SUGGESTED_TITLE: ${{ steps.suggest-title.outputs.SUGGESTED_TITLE }}
steps:
- name: Check PR Title
id: check-title
uses: naveenk1223/action-pr-title@master
with:
regex: '^[a-zA-Z]+(\([a-zA-Z]+\))?: .+'
allowed_prefixes: "feat,fix,docs,style,refactor,test,chore,ci,perf,revert"
prefix_case_sensitive: false
min_length: 1
max_length: -1
- name: Set Suggested Title
id: suggest-title
if: failure()
run: |
# Extract the current PR title
current_title="${{ github.event.pull_request.title }}"
# Parse the current PR title
IFS=':' read -r -a parts <<< "$current_title"
type="${parts[0]}"
description="${parts[1]}"
# Generate a new title
suggested_title="$type(new_scope): $description"
# Set the new title as an output
echo "SUGGESTED_TITLE=$suggested_title" >> $GITHUB_ENV
suggest-title:
runs-on: ubuntu-latest
needs: title-check
steps:
- name: Comment on PR with suggested title
run: |
echo "Suggested PR title: $SUGGESTED_TITLE"
gh pr comment ${{ github.event.number }} --body "The PR title does not follow the required format. Consider using the following suggested title: $SUGGESTED_TITLE"