|
1 | | -# name: PR Commit Convention Linter |
2 | | - |
3 | | -# on: |
4 | | -# pull_request: |
5 | | -# types: [opened, synchronize, reopened] |
6 | | - |
7 | | -# permissions: |
8 | | -# pull-requests: write |
9 | | - |
10 | | -# jobs: |
11 | | -# commit-lint: |
12 | | -# runs-on: ubuntu-latest |
13 | | - |
14 | | -# steps: |
15 | | - |
16 | | -# - name: Minimal Git clone without actions/checkout |
17 | | -# run: | |
18 | | -# git init |
19 | | -# git remote add origin https://github.com/${{ github.repository }}.git |
20 | | -# git fetch origin ${{ github.event.pull_request.head.ref }} --depth=1 |
21 | | -# git checkout FETCH_HEAD |
22 | | - |
23 | | - |
24 | | -# - name: Install GitHub CLI |
25 | | -# run: | |
26 | | -# sudo apt-get update |
27 | | -# sudo apt-get install -y gh |
28 | | - |
29 | | -# - name: Get latest commit message |
30 | | -# id: get_commit |
31 | | -# run: | |
32 | | -# git log -1 --pretty=format:"%s" > commit.txt |
33 | | - |
34 | | -# - name: Validate commit message |
35 | | -# id: validate |
36 | | -# run: | |
37 | | -# line=$(cat commit.txt) |
38 | | -# echo "Checking commit: $line" |
39 | | - |
40 | | -# # 메시지 길이 확인 (50자 초과면 경고) |
41 | | -# if [[ ${#line} -gt 72 ]]; then |
42 | | -# echo "::warning::⚠️ Commit message is longer than 72 characters." |
43 | | -# fi |
44 | | - |
45 | | -# # 정규식: 타입(scope): 메시지 (소문자 시작, 마침표 금지) |
46 | | -# pattern='^(Feat|Fix|Docs|Style|Refactor|Test|Chore|Ci|Perf|Build)(\([a-zA-Z0-9_-]+\))?: [a-z][^\.]{0,69}$' |
47 | | - |
48 | | -# if ! [[ "$line" =~ $pattern ]] && ! [[ "$line" =~ ^Merge.* ]]; then |
49 | | -# echo "::error::❌ Invalid commit message: $line" |
50 | | -# echo "invalid=1" >> $GITHUB_OUTPUT |
51 | | -# else |
52 | | -# echo "invalid=0" >> $GITHUB_OUTPUT |
53 | | -# fi |
54 | | - |
55 | | -# - name: Comment on PR if invalid |
56 | | -# if: steps.validate.outputs.invalid == '1' |
57 | | -# run: | |
58 | | -# gh pr comment "$PR_NUMBER" --body "🚫 One or more commit messages in this PR **do not follow the commit convention.** |
59 | | - |
60 | | -# Please revise them to match the format: \`Feat(actions): add something cool\` |
61 | | - |
62 | | -# 📘 See our [Wiki](https://github.com/khyeonm/2025_Advanced_Programming/wiki/Git-Commit-Convention) for details. |
63 | | - |
64 | | -# Thank you!" |
65 | | - |
66 | | -# env: |
67 | | -# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
68 | | -# PR_NUMBER: ${{ github.event.pull_request.number }} |
69 | | - |
70 | 1 | name: PR Commit Convention Linter |
71 | 2 |
|
72 | 3 | on: |
|
0 commit comments