From b254fdf31ddaad044efd73b9f96f8d8b76b74b50 Mon Sep 17 00:00:00 2001 From: "Trez.One" Date: Wed, 18 Dec 2024 08:24:13 -0500 Subject: [PATCH] JSON formatting fix... --- .../workflows/branch-sonarscan-pr-merge.yml | 49 +++++++++++-------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/.gitea/workflows/branch-sonarscan-pr-merge.yml b/.gitea/workflows/branch-sonarscan-pr-merge.yml index 135c8c68..666f7a77 100644 --- a/.gitea/workflows/branch-sonarscan-pr-merge.yml +++ b/.gitea/workflows/branch-sonarscan-pr-merge.yml @@ -47,7 +47,7 @@ jobs: "body": "This is an automated PR created by Gitea Actions.", "base": "main", "head": "${{ github.ref_name }}" - }' -s | jq '{index: .number}' > pr_created.json + }' | jq '{index: .number}' > pr_created.json echo "pr_created=$(jq -c . pr_created.json)" >> "$GITHUB_OUTPUT" # Job 2: Run SonarQube Analysis @@ -80,27 +80,36 @@ jobs: sonar-project-key: rinoa-docker sonar-host-url: ${{ secrets.SONARQUBE_HOST }} sonar-token: ${{ secrets.SONARQUBE_TOKEN }} - - - name: Check Quality Gate Status - id: check-quality-gate-status - run: | - echo "Quality Gate Status: ${{ steps.quality-gate-check.outputs.project-status }}" - echo "Quality Gate Result: " - echo "${{ steps.quality-gate-check.outputs.quality-gate-result }}" > input.txt - sed -E 's/([^,{:]*):/\1":/g; s/: ([^,}\]]*)/: "\1"/g' input.txt | sed 's/,\s*}/}/g; s/,\s*\]/]/g' > fixed.json - jq '.' fixed.json - cat fixed.json - echo "quality-gate-report=$(cat fixed.json)" >> "$GITHUB_OUTPUT" - - - name: Convert JSON report to markdown - id: convert-json-to-md - uses: parkerbxyz/json-to-markdown-table@v1.1.2 - with: - json: toJSON(${{ steps.quality-gate-check.outputs.quality-gate-result }}) - - name: Verify markdown output + - name: Create Input File run: | - echo "${{ steps.convert-json-to-md.outputs.table }}" + echo "Creating invalid input..." + cat < input.txt + ${{ steps.quality-gate-check.outputs.quality-gate-result }} + EOF + + - name: Fix JSON Formatting + id: fix-json + run: | + echo "Fixing invalid JSON..." + sed -E 's/([^,{:]*):/\1":/g; s/: ([^,}\]]*)/: "\1"/g' input.txt | \ + sed 's/,\s*}/}/g; s/,\s*\]/]/g' > fixed.json + cat fixed.json + + - name: Validate Fixed JSON + run: | + echo "Validating JSON with jq..." + jq '.' fixed.json + + # - name: Convert JSON report to markdown + # id: convert-json-to-md + # uses: parkerbxyz/json-to-markdown-table@v1.1.2 + # with: + # json: toJSON(${{ steps.quality-gate-check.outputs.quality-gate-result }}) + + # - name: Verify markdown output + # run: | + # echo "${{ steps.convert-json-to-md.outputs.table }}" # Step 2: Post SonarQube results as comment (using curl commands and Gitea API) # - name: Post SonarQube Results as Comment