diff --git a/.gitea/workflows/deployment.yml b/.gitea/workflows/deployment.yml index da169db9..76d80af0 100644 --- a/.gitea/workflows/deployment.yml +++ b/.gitea/workflows/deployment.yml @@ -26,13 +26,18 @@ jobs: run: | tea login add --name gitea-rinoa --url ${{ secrets.RINOA_GITEA_URL }} --user gitea-sonarqube-bot --password "${{ secrets.BOT_GITEA_PASSWORD }}" --token ${{ secrets.BOT_GITEA_TOKEN }} tea login default gitea-rinoa - echo "Checking if PR exists for ${{ github.ref_name }}" - tea pr ls --repo ${{ github.repository }} --state open --fields index,title,head,state --output csv | egrep -q '${{ github.ref_name }}' - if [ $? -eq 0 ]; then + + echo "Checking if PR exists for branch: ${{ github.ref_name }}" + PR_EXISTS=$(tea pr ls --repo "${{ github.repository }}" --state open --fields index,title,head,state --output csv | grep -c "${{ github.ref_name }}") + + if [ "$PR_EXISTS" -ge 1 ]; then echo "PR exists, skipping creation..." - elif [ $? -eq 1 ]; then + elif [ "$PR_EXISTS" -eq 0 ]; then echo "PR does not exist, creating PR..." tea pr c -r "${{ github.repository }}" -t "Automated PR for ${{ github.ref_name }}" -d "Automated PR for ${{ github.ref_name }}" + else + echo "Error determining PR status. Exiting..." + exit 1 fi docker-compose-test: