|
| 1 | +name: PR |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, edited, synchronize, reopened] |
| 6 | + branches: |
| 7 | + - main |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + pull-requests: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + title: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Validate PR title follows Conventional Commits |
| 18 | + env: |
| 19 | + TITLE: ${{ github.event.pull_request.title }} |
| 20 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 21 | + run: | |
| 22 | + if echo "$TITLE" | grep -qE "^(feat|fix|docs|style|refactor|test|chore|build|ci|perf|revert)(\(.+\))?(!)?: .+"; then |
| 23 | + echo "PR title is valid: $TITLE" |
| 24 | + exit 0 |
| 25 | + fi |
| 26 | +
|
| 27 | + BODY=$(cat <<'COMMENT' |
| 28 | + ### ⚠️ Invalid PR Title |
| 29 | +
|
| 30 | + PR title must follow the **Conventional Commits** format since we use squash merge: |
| 31 | +
|
| 32 | + ``` |
| 33 | + <type>[optional scope][!]: <description> |
| 34 | + ``` |
| 35 | +
|
| 36 | + **Allowed types:** `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore`, `build`, `ci`, `perf`, `revert` |
| 37 | +
|
| 38 | + **Examples:** |
| 39 | + - `feat: add new feature` |
| 40 | + - `fix(api): resolve null pointer` |
| 41 | + - `feat!: breaking change` |
| 42 | + - `chore(deps): update dependencies` |
| 43 | + COMMENT |
| 44 | + ) |
| 45 | +
|
| 46 | + # Post comment on PR |
| 47 | + gh api "repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \ |
| 48 | + -X POST -f body="$BODY" |
| 49 | +
|
| 50 | + echo "::error::PR title must follow Conventional Commits format" |
| 51 | + exit 1 |
| 52 | +
|
| 53 | + review: |
| 54 | + runs-on: ubuntu-latest |
| 55 | + steps: |
| 56 | + - uses: actions/checkout@v4 |
| 57 | + - uses: AxeForging/reviewforge@main |
| 58 | + with: |
| 59 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 60 | + AI_PROVIDER: gemini |
| 61 | + AI_MODEL: gemini-2.5-flash |
| 62 | + AI_API_KEY: ${{ secrets.GEMINI_API_KEY }} |
| 63 | + SHOW_TOKEN_USAGE: true |
| 64 | + INCREMENTAL: false |
| 65 | + REVIEW_RULES: concise |
| 66 | + |
| 67 | + validate: |
| 68 | + runs-on: ubuntu-latest |
| 69 | + steps: |
| 70 | + - uses: actions/checkout@v4 |
| 71 | + - uses: AxeForging/structlint@main |
| 72 | + with: |
| 73 | + config: .structlint.yaml |
| 74 | + comment-on-pr: "true" |
| 75 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments