Skip to content

Commit c73f89a

Browse files
committed
fix: improve logic to open PR only of there is none already open
1 parent 7355a32 commit c73f89a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

.github/workflows/auto-pr.yaml

+6-5
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,21 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v4
1414
- name: Verify if PR already open
15+
id: pr-check
1516
env:
1617
GH_TOKEN: ${{ secrets.PAT }}
1718
run: |
1819
prs_list=$(gh pr list --search "${{ github.ref_name }}")
1920
echo "${prs_list}"
20-
for pr in $prs_list; do
21-
echo ${pr}
22-
done
2321
if [ -n "$prs_list" ]; then
2422
echo "PR already opened"
25-
exit 0
23+
echo "::set-output name=pr_exists::true"
24+
else
25+
echo "::set-output name=pr_exists::false"
2626
fi
2727
28-
- name: create pull request
28+
- name: Create pull request
29+
if: steps.pr-check.outputs.pr_exists == 'false' # Only run if no PR exists
2930
run: gh pr create -B main -H ${{ github.ref_name }} --title 'Merge ${{ github.ref_name }} into main' --body 'Created by Github action'
3031
env:
3132
GITHUB_TOKEN: ${{ secrets.PAT }}

0 commit comments

Comments
 (0)