-
-
Notifications
You must be signed in to change notification settings - Fork 158
40 lines (33 loc) · 1.49 KB
/
issue_creation_workflow.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
name: Issue Creation Workflow
on:
issues:
types: [opened]
jobs:
check-contributor-issues:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '14'
- name: Retrieve Contributors
run: |
CONTRIBUTORS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/contributors | jq -r '.[].login')
echo "::set-output name=contributors::$CONTRIBUTORS"
- name: Count Open Issues for Each Contributor
id: count-issues
run: |
for contributor in ${{ steps.retrieve-contributors.outputs.contributors }}; do
ISSUE_COUNT=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/search/issues?q=is:open+author:${contributor}+repo:${{ github.repository }}" | jq -r '.total_count')
echo "::set-output name=${contributor}_issue_count::$ISSUE_COUNT"
done
- name: Check Contributor's Open Issues Count
run: |
contributor=${{ github.event.issue.user.login }}
issue_count=${{ steps.count-issues.outputs["${contributor}_issue_count"] }}
if [ "$issue_count" -ge 4 ]; then
echo "Contributor $contributor has $issue_count open issues. Please complete your existing open issues before creating a new one."
exit 1
fi