Skip to content

Commit dc650e3

Browse files
Fix dynamic key issue in workflow file
1 parent e8a245d commit dc650e3

File tree

1 file changed

+72
-4
lines changed

1 file changed

+72
-4
lines changed

.github/workflows/pr_creation_workflow.yml

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,70 @@
1+
# name: PR Creation Workflow
2+
3+
# on:
4+
# pull_request:
5+
# types: [opened, edited]
6+
7+
# jobs:
8+
# check-pr:
9+
# runs-on: ubuntu-latest
10+
11+
# steps:
12+
# - name: Checkout repository
13+
# uses: actions/checkout@v4
14+
15+
# - name: Set up Node.js
16+
# uses: actions/setup-node@v4
17+
# with:
18+
# node-version: '14'
19+
20+
# - name: Validate PR Description
21+
# id: validate-pr
22+
# run: |
23+
# pr_body="${{ github.event.pull_request.body }}"
24+
# required_checkboxes=(
25+
# "I have performed a self-review of my code."
26+
# "I have read and followed the Contribution Guidelines."
27+
# "I have tested the changes thoroughly before submitting this pull request."
28+
# "I have provided relevant issue numbers, screenshots, and videos after making the changes."
29+
# "I have commented my code, particularly in hard-to-understand areas."
30+
# "I have followed the code style guidelines of this project."
31+
# "I have checked for any existing open issues that my pull request may address."
32+
# "I have ensured that my changes do not break any existing functionality."
33+
# "Each contributor is allowed to create a maximum of 4 issues per day. This helps us manage and address issues efficiently."
34+
# "I have read the resources for guidance listed below."
35+
# "I have not used AI-generated content (e.g., ChatGPT, other AI tools)."
36+
# "I have not used content from existing sites (e.g., text, images)."
37+
# "I have followed all security rules and only shared trusted resources."
38+
# )
39+
# for checkbox in "${required_checkboxes[@]}"; do
40+
# if [[ "$pr_body" != *"$checkbox"* ]]; then
41+
# echo "Missing required checkbox: $checkbox"
42+
# exit 1
43+
# fi
44+
# done
45+
46+
# - name: Retrieve Contributors
47+
# run: |
48+
# CONTRIBUTORS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/contributors | jq -r '.[].login')
49+
# echo "::set-output name=contributors::$CONTRIBUTORS"
50+
51+
# - name: Count Open Issues for Each Contributor
52+
# id: count-issues
53+
# run: |
54+
# for contributor in ${{ steps.retrieve-contributors.outputs.contributors }}; do
55+
# 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')
56+
# echo "::set-output name=${contributor}_issue_count::$ISSUE_COUNT"
57+
# done
58+
59+
# - name: Check Contributor's Open Issues Count
60+
# run: |
61+
# contributor=${{ github.event.pull_request.user.login }}
62+
# issue_count=${{ steps.count-issues.outputs["${contributor}_issue_count"] }}
63+
# if [ "$issue_count" -ge 4 ]; then
64+
# echo "Contributor $contributor has $issue_count open issues. Please complete your existing open issues before creating a new one."
65+
# exit 1
66+
# fi
67+
168
name: PR Creation Workflow
269

370
on:
@@ -44,22 +111,23 @@ jobs:
44111
done
45112
46113
- name: Retrieve Contributors
114+
id: retrieve-contributors
47115
run: |
48116
CONTRIBUTORS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/contributors | jq -r '.[].login')
49-
echo "::set-output name=contributors::$CONTRIBUTORS"
117+
echo "contributors=$CONTRIBUTORS" >> $GITHUB_ENV
50118
51119
- name: Count Open Issues for Each Contributor
52120
id: count-issues
53121
run: |
54-
for contributor in ${{ steps.retrieve-contributors.outputs.contributors }}; do
122+
for contributor in ${{ env.contributors }}; do
55123
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')
56-
echo "::set-output name=${contributor}_issue_count::$ISSUE_COUNT"
124+
echo "${contributor}_issue_count=$ISSUE_COUNT" >> $GITHUB_ENV
57125
done
58126
59127
- name: Check Contributor's Open Issues Count
60128
run: |
61129
contributor=${{ github.event.pull_request.user.login }}
62-
issue_count=${{ steps.count-issues.outputs["${contributor}_issue_count"] }}
130+
issue_count=$(printenv | grep "${contributor}_issue_count" | cut -d '=' -f2)
63131
if [ "$issue_count" -ge 4 ]; then
64132
echo "Contributor $contributor has $issue_count open issues. Please complete your existing open issues before creating a new one."
65133
exit 1

0 commit comments

Comments
 (0)