Skip to content

The Open Source DocuSign Alternative.

chore: prevent frequent commenting for semantic pr titles

Adithya Krishnaf9139a54a53a
diff --git a/.github/workflows/semantic-pull-requests.yml b/.github/workflows/semantic-pull-requests.yml
index 7685562b5..37b764652 100644
--- a/.github/workflows/semantic-pull-requests.yml
+++ b/.github/workflows/semantic-pull-requests.yml
@@ -16,6 +16,24 @@ jobs:
name: Validate PR title
runs-on: ubuntu-latest
steps:
+ - name: Check PR creator's previous activity
+ id: check_activity
+ run: |
+ CREATOR=$(curl -s "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" | jq -r '.user.login')
+ ACTIVITY=$(curl -s "https://api.github.com/search/commits?q=author:${CREATOR}+repo:${{ github.repository }}" | jq -r '.total_count')
+ if [ "$ACTIVITY" -eq 0 ]; then
+ echo "::set-output name=is_new::true"
+ else
+ echo "::set-output name=is_new::false"
+ fi
+
+ - name: Count PRs created by user
+ id: count_prs
+ run: |
+ CREATOR=$(curl -s "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" | jq -r '.user.login')
+ PR_COUNT=$(curl -s "https://api.github.com/search/issues?q=type:pr+is:open+author:${CREATOR}+repo:${{ github.repository }}" | jq -r '.total_count')
+ echo "::set-output name=pr_count::$PR_COUNT"
+
- uses: amannn/action-semantic-pull-request@v5
id: lint_pr_title
env:
@@ -36,7 +54,7 @@ jobs:
${{ steps.lint_pr_title.outputs.error_message }}
```
- - if: ${{ steps.lint_pr_title.outputs.error_message == null }}
+ - if: ${{ steps.lint_pr_title.outputs.error_message == null && steps.check_activity.outputs.is_new == 'false' && steps.count_prs.outputs.pr_count < 2}}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-title-lint-error