Skip to content

Commit

Permalink
fix: improve logic to open PR only of there is none already open
Browse files Browse the repository at this point in the history
  • Loading branch information
sibelly committed Oct 23, 2024
1 parent 7355a32 commit c73f89a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/auto-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Verify if PR already open
id: pr-check
env:
GH_TOKEN: ${{ secrets.PAT }}
run: |
prs_list=$(gh pr list --search "${{ github.ref_name }}")
echo "${prs_list}"
for pr in $prs_list; do
echo ${pr}
done
if [ -n "$prs_list" ]; then
echo "PR already opened"
exit 0
echo "::set-output name=pr_exists::true"
else
echo "::set-output name=pr_exists::false"
fi
- name: create pull request
- name: Create pull request
if: steps.pr-check.outputs.pr_exists == 'false' # Only run if no PR exists
run: gh pr create -B main -H ${{ github.ref_name }} --title 'Merge ${{ github.ref_name }} into main' --body 'Created by Github action'
env:
GITHUB_TOKEN: ${{ secrets.PAT }}

0 comments on commit c73f89a

Please sign in to comment.