Skip to content

Commit 27b3886

Browse files
committed
f
1 parent 76f7ebb commit 27b3886

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

.github/workflows/auto_merge_approved_prs.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ jobs:
3636
if: steps.check_workflows.outputs.should_continue == 'true'
3737
run: |
3838
authorized_user="carlospolop"
39-
merged_count=0
4039
max_merges=2
4140
4241
echo "Authorized user: $authorized_user"
@@ -50,9 +49,13 @@ jobs:
5049
exit 0
5150
fi
5251
52+
# Create a temp file to track merge count
53+
echo "0" > /tmp/merged_count
54+
5355
# Process each PR
5456
echo "$prs" | jq -r '.[] | @base64' | while IFS= read -r pr_data; do
55-
if [ "$merged_count" -ge "$max_merges" ]; then
57+
current_count=$(cat /tmp/merged_count)
58+
if [ "$current_count" -ge "$max_merges" ]; then
5659
echo "Reached maximum merge limit ($max_merges). Stopping."
5760
break
5861
fi
@@ -100,7 +103,9 @@ jobs:
100103
# Merge the PR (specify repo explicitly since we're not in a git directory)
101104
if gh pr merge "$pr_number" --merge --delete-branch --repo "$GITHUB_REPOSITORY"; then
102105
echo "Successfully merged PR #$pr_number: $pr_title"
103-
merged_count=$((merged_count + 1))
106+
# Update merge count in temp file
107+
current_count=$(cat /tmp/merged_count)
108+
echo $((current_count + 1)) > /tmp/merged_count
104109
else
105110
echo "Failed to merge PR #$pr_number: $pr_title"
106111
fi
@@ -115,6 +120,11 @@ jobs:
115120
rm -f "/tmp/has_merge_comment_$pr_number"
116121
done
117122
118-
echo "Auto-merge process completed. Merged $merged_count PRs."
123+
# Read final merge count from temp file
124+
final_count=$(cat /tmp/merged_count)
125+
echo "Auto-merge process completed. Merged $final_count PRs."
126+
127+
# Clean up merge count file
128+
rm -f /tmp/merged_count
119129
env:
120130
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)