Skip to content

Commit 0d6c7af

Browse files
authored
Create issue_creation_workflow.yml
1 parent 0f09ca9 commit 0d6c7af

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Issue Creation Workflow
2+
3+
on:
4+
issues:
5+
types: [opened]
6+
7+
jobs:
8+
check-contributor-issues:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v2
14+
15+
- name: Set up Node.js
16+
uses: actions/setup-node@v2
17+
with:
18+
node-version: '14'
19+
20+
- name: Retrieve Contributors
21+
run: |
22+
CONTRIBUTORS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/contributors | jq -r '.[].login')
23+
echo "::set-output name=contributors::$CONTRIBUTORS"
24+
25+
- name: Count Open Issues for Each Contributor
26+
id: count-issues
27+
run: |
28+
for contributor in ${{ steps.retrieve-contributors.outputs.contributors }}; do
29+
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')
30+
echo "::set-output name=${contributor}_issue_count::$ISSUE_COUNT"
31+
done
32+
33+
- name: Check Contributor's Open Issues Count
34+
run: |
35+
contributor=${{ github.event.issue.user.login }}
36+
issue_count=${{ steps.count-issues.outputs["${contributor}_issue_count"] }}
37+
if [ "$issue_count" -ge 4 ]; then
38+
echo "Contributor $contributor has $issue_count open issues. Please complete your existing open issues before creating a new one."
39+
exit 1
40+
fi

0 commit comments

Comments
 (0)