From c73f89aa5ad14d010388f3dd855612fe90cbe3a0 Mon Sep 17 00:00:00 2001 From: sibelly Date: Wed, 23 Oct 2024 16:42:26 -0400 Subject: [PATCH] fix: improve logic to open PR only of there is none already open --- .github/workflows/auto-pr.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/auto-pr.yaml b/.github/workflows/auto-pr.yaml index 80bb4ca..577a01d 100644 --- a/.github/workflows/auto-pr.yaml +++ b/.github/workflows/auto-pr.yaml @@ -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 }} \ No newline at end of file