From 9be225c89e405f4a41713691e0cef0d9c663b02c Mon Sep 17 00:00:00 2001 From: "Trez.One" Date: Mon, 16 Dec 2024 21:44:41 -0500 Subject: [PATCH] Path fix on L31 for gocurl. --- .../workflows/branch-sonarscan-pr-merge.yml | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/.gitea/workflows/branch-sonarscan-pr-merge.yml b/.gitea/workflows/branch-sonarscan-pr-merge.yml index ada2efdb..f34c0ddd 100644 --- a/.gitea/workflows/branch-sonarscan-pr-merge.yml +++ b/.gitea/workflows/branch-sonarscan-pr-merge.yml @@ -28,22 +28,35 @@ jobs: id: check-pr uses: prasiman/gocurl@v1 with: - url: ${{ vars.RINOA_GITEA_URL }}/api/v1/repos/${{ github.repository }}/pulls/${{ github.base_ref }}/${{ github.ref_name }} + url: ${{ vars.RINOA_GITEA_URL }}/api/v1/repos/${{ github.repository }}/pulls/main/${{ github.ref_name }} method: "GET" headers: '{ "Authorization": "token ${{ secrets.GITEA_API_TOKEN }}" }' + accept: 200,201,204,404 log-response: true - - name: Evaluate Existing PR Status - id: eval-pr + - name: Convert gocurl Response to JSON + id: preprocess-response run: | - echo "Checking if PR already exists..." - if [ "${{ steps.check-pr.outputs.response }}" = "[]" ]; then - echo "pr_exists=false" >> $GITHUB_ENV - echo "No existing PR found for branch." - else - echo "pr_exists=true" >> $GITHUB_ENV - echo "PR already exists. Continuing..." - fi + RESPONSE='${{ steps.check-pr.outputs.response }}' + + # Extract the 'data' and 'status_code' fields into JSON format + DATA=$(echo "$RESPONSE" | grep -oP 'data:\K[^\s]+' || echo "null") + STATUS_CODE=$(echo "$RESPONSE" | grep -oP 'status_code:\K[^\s]+' || echo "0") + + # Create valid JSON output + echo "{ \"data\": $DATA, \"status_code\": $STATUS_CODE }" > response.json + cat response.json + + # Export as output + echo "response_json=$(cat response.json)" >> $GITHUB_OUTPUT + + - name: Parse PR Response + id: parse-pr + uses: yakubique/json-utils@v1.8 + with: + input: ${{ steps.preprocess-response.outputs.response_json }} + action: "get" + key: "" # Step 2: Create PR if none exists - name: Create PR in Gitea