From 7552cdb114a77a78ffdf713b790407a2b69ce354 Mon Sep 17 00:00:00 2001 From: Parth Gohil <138430690+parthpnx@users.noreply.github.com> Date: Thu, 11 Apr 2024 11:20:34 +0530 Subject: [PATCH 1/6] feat(ci): conventional-commit linter for PRs to main --- .../validate-conventional-commits.yaml | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/validate-conventional-commits.yaml diff --git a/.github/workflows/validate-conventional-commits.yaml b/.github/workflows/validate-conventional-commits.yaml new file mode 100644 index 0000000..c737ea8 --- /dev/null +++ b/.github/workflows/validate-conventional-commits.yaml @@ -0,0 +1,25 @@ +name: Validate Conventional Commits + +on: + pull_request: + branches: + - main + +jobs: + validate_commits: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install Node.js and npm + uses: actions/setup-node@v2 + with: + node-version: '20.12.2' + + - name: Install conventional-changelog-lint + run: npm install -g conventional-changelog-lint + + - name: Validate commits + run: npx conventional-changelog-lint --from=main --to=$GITHUB_SHA \ No newline at end of file From 5a1e2137ce0d951f10ed98180748d714c45d6506 Mon Sep 17 00:00:00 2001 From: Parth Gohil <138430690+parthpnx@users.noreply.github.com> Date: Thu, 11 Apr 2024 11:28:49 +0530 Subject: [PATCH 2/6] fix(ci): variable for source branch --- .github/workflows/validate-conventional-commits.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate-conventional-commits.yaml b/.github/workflows/validate-conventional-commits.yaml index c737ea8..578d928 100644 --- a/.github/workflows/validate-conventional-commits.yaml +++ b/.github/workflows/validate-conventional-commits.yaml @@ -22,4 +22,4 @@ jobs: run: npm install -g conventional-changelog-lint - name: Validate commits - run: npx conventional-changelog-lint --from=main --to=$GITHUB_SHA \ No newline at end of file + run: npx conventional-changelog-lint --from=main --to=${GITHUB_REF} \ No newline at end of file From 0ac3a259a2000a60b9426832c7d9a1e379262974 Mon Sep 17 00:00:00 2001 From: Parth Gohil <138430690+parthpnx@users.noreply.github.com> Date: Thu, 11 Apr 2024 12:37:48 +0530 Subject: [PATCH 3/6] fix(ci): 0 fetch-depth --- .github/workflows/validate-conventional-commits.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/validate-conventional-commits.yaml b/.github/workflows/validate-conventional-commits.yaml index 578d928..7ac78ae 100644 --- a/.github/workflows/validate-conventional-commits.yaml +++ b/.github/workflows/validate-conventional-commits.yaml @@ -11,7 +11,9 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Install Node.js and npm uses: actions/setup-node@v2 @@ -19,7 +21,7 @@ jobs: node-version: '20.12.2' - name: Install conventional-changelog-lint - run: npm install -g conventional-changelog-lint + run: npm install --save-dev conventional-changelog-lint - name: Validate commits - run: npx conventional-changelog-lint --from=main --to=${GITHUB_REF} \ No newline at end of file + run: npx conventional-changelog-lint --from=origin/main --to=origin/${{ github.head_ref }} \ No newline at end of file From e27858960d91e4140718a4f3f32ec9f7e1b9dbec Mon Sep 17 00:00:00 2001 From: Parth Gohil <138430690+parthpnx@users.noreply.github.com> Date: Thu, 11 Apr 2024 19:17:01 +0530 Subject: [PATCH 4/6] fix(ci): validate pr title and pr body --- .github/workflows/validate-conventional-commits.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/validate-conventional-commits.yaml b/.github/workflows/validate-conventional-commits.yaml index 7ac78ae..138cb5f 100644 --- a/.github/workflows/validate-conventional-commits.yaml +++ b/.github/workflows/validate-conventional-commits.yaml @@ -24,4 +24,10 @@ jobs: run: npm install --save-dev conventional-changelog-lint - name: Validate commits - run: npx conventional-changelog-lint --from=origin/main --to=origin/${{ github.head_ref }} \ No newline at end of file + run: npx conventional-changelog-lint --from=origin/main --to=origin/${{ github.head_ref }} + + - name: validate PR title + run: echo ${{ github.event.pull_request.title }} | npx conventional-changelog-lint + + - name: validate PR body + run: if [[ ${{ github.event.pull_request.body }} =~ "(.*\n)+(.*)" ]]; then exit 0; else exit 1; fi \ No newline at end of file From b705938dd4db9deb4aee8ba5f009a92c1678f64b Mon Sep 17 00:00:00 2001 From: Parth Gohil <138430690+parthpnx@users.noreply.github.com> Date: Thu, 11 Apr 2024 19:18:57 +0530 Subject: [PATCH 5/6] fix(ci): syntax fixes --- .github/workflows/validate-conventional-commits.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate-conventional-commits.yaml b/.github/workflows/validate-conventional-commits.yaml index 138cb5f..caba26f 100644 --- a/.github/workflows/validate-conventional-commits.yaml +++ b/.github/workflows/validate-conventional-commits.yaml @@ -27,7 +27,7 @@ jobs: run: npx conventional-changelog-lint --from=origin/main --to=origin/${{ github.head_ref }} - name: validate PR title - run: echo ${{ github.event.pull_request.title }} | npx conventional-changelog-lint + run: echo "${{ github.event.pull_request.title }}" | npx conventional-changelog-lint - name: validate PR body - run: if [[ ${{ github.event.pull_request.body }} =~ "(.*\n)+(.*)" ]]; then exit 0; else exit 1; fi \ No newline at end of file + run: if [[ "${{ github.event.pull_request.body }}" =~ "(.*\n)+(.*)" ]]; then exit 0; else exit 1; fi \ No newline at end of file From e288ed3b07c3d88319bfa7f521ddc7108354069e Mon Sep 17 00:00:00 2001 From: Parth Gohil <138430690+parthpnx@users.noreply.github.com> Date: Thu, 11 Apr 2024 19:21:22 +0530 Subject: [PATCH 6/6] fix(ci): removed pr body validation --- .github/workflows/validate-conventional-commits.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate-conventional-commits.yaml b/.github/workflows/validate-conventional-commits.yaml index caba26f..13821bd 100644 --- a/.github/workflows/validate-conventional-commits.yaml +++ b/.github/workflows/validate-conventional-commits.yaml @@ -29,5 +29,5 @@ jobs: - name: validate PR title run: echo "${{ github.event.pull_request.title }}" | npx conventional-changelog-lint - - name: validate PR body - run: if [[ "${{ github.event.pull_request.body }}" =~ "(.*\n)+(.*)" ]]; then exit 0; else exit 1; fi \ No newline at end of file + # - name: validate PR body + # run: if [[ "${{ github.event.pull_request.body }}" =~ "(.*\n)+(.*)" ]]; then exit 0; else exit 1; fi \ No newline at end of file