diff --git a/.gitea/workflows/branch-sonarscan-pr-merge.yml b/.gitea/workflows/branch-sonarscan-pr-merge.yml index 51922ce2..f492dbb2 100644 --- a/.gitea/workflows/branch-sonarscan-pr-merge.yml +++ b/.gitea/workflows/branch-sonarscan-pr-merge.yml @@ -108,18 +108,35 @@ jobs: PR_NUMBER: ${{ needs.check-and-create-pr.outputs.pr_number }} SQ_RESULTS: ${{ steps.convert-json-to-md.outputs.table }} QG_STATUS: ${{ steps.quality-gate.outputs.quality-gate-status }} + RINOA_GITEA_URL: ${{ vars.RINOA_GITEA_URL }} + GITHUB_REPOSITORY: ${{ github.repository }} + BOT_GITEA_TOKEN: ${{ secrets.BOT_GITEA_TOKEN }} run: | - payload=$(jq -n --arg body "SonarQube analysis results:\n\n${{ env.SQ_RESULTS }}\n\n${{ env.QG_STATUS }}" \ - '{ - body: $body - }') - echo "${payload}" - curl ${{ vars.RINOA_GITEA_URL }}/api/v1/repos/${{ github.repository }}/pulls/${PR_NUMBER}/reviews \ - -X 'POST' \ - -H 'Accept: application/json' \ - -H 'Authorization: token ${{ secrets.BOT_GITEA_TOKEN }}' \ - -H 'Content-Type: application/json' \ - -d '${{ env.payload }}' -s -w "%http_code%" -i + payload=$(jq -n \ + --arg body "SonarQube analysis results:\n\n${SQ_RESULTS}\n\n${QG_STATUS}" \ + '{ body: $body }') + + + echo "Constructed Payload:" + echo "$payload" + + response=$(curl -s -o response.json -w "%{http_code}" \ + -X POST \ + -H "Accept: application/json" \ + -H "Authorization: token ${BOT_GITEA_TOKEN}" \ + -H "Content-Type: application/json" \ + -d "$payload" \ + "${RINOA_GITEA_URL}/api/v1/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/reviews") + + echo "HTTP Status Code: $response" + echo "Response Body:" + cat response.json + + if [ "$response" -ne 200 ]; then + echo "Error: Failed to post comment. HTTP Status Code: $response" + exit 1 + fi + # Job 3: Merge PR if Quality Gate passes # merge-pr: