Re-validating comment post functionality.

This commit is contained in:
2024-12-20 15:09:16 -05:00
committed by Trez.One
parent 364f8b8f47
commit bb30b7b14f
+45 -53
View File
@@ -6,7 +6,7 @@ on:
- main - main
jobs: jobs:
# Job 1: Check if PR exists and create one if the branch is new
check-and-create-pr: check-and-create-pr:
name: Check and Create PR name: Check and Create PR
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -97,7 +97,6 @@ jobs:
env: env:
DOCKER_HOST: tcp://dockerproxy:2375 DOCKER_HOST: tcp://dockerproxy:2375
# Job 3: Merge PR if Quality Gate passes
scan-json-merge-pr: scan-json-merge-pr:
name: Merge PR if checks pass name: Merge PR if checks pass
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -106,60 +105,53 @@ jobs:
- name: Checkout Code - name: Checkout Code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Parse Docker Compose Dry Run Output - name: JSON clean-up for Custom Quality Gate Check...
uses: niklas-weber/scan-log@v1.0.2 id: json-cleanup
run: |
echo "Cleaning up quality gate response..."
echo '${{ needs.sonarqube-analysis-dry-run.outputs.qg_results }}' > qg_input.txt
sed -E 's/([a-zA-Z0-9_]+):/\\"\1\\":/g; s/:([^",{}\[\]]+)/:"\1"/g' qg_input.txt > qg_raw.json
jq -c '.' qg_raw.json > qg_fixed_json.json
echo "qgfixedjson=$(cat qg_fixed_json.json)" >> $GITHUB_OUTPUT
echo "JSON cleanup complete."
projstatus=$(jq -r '.projectStatus.status' qg_fixed_json.json)
caycStatus=$(jq -r '.projectStatus.caycStatus' qg_fixed_json.json)
conditions=$(jq -c '.projectStatus.conditions' qg_fixed_json.json)
echo "projstatus=${projstatus}" >> $GITHUB_OUTPUT
echo "caycStatus=${caycStatus}" >> $GITHUB_OUTPUT
echo "conditions=${conditions}" >> $GITHUB_OUTPUT
- name: Convert JSON to Markdown Table
id: convert-json-to-md
uses: buildingcash/json-to-markdown-table-action@v1.1.0
with: with:
error: 'level=' json: "${{ steps.json-cleanup.outputs.conditions }}"
gh-token: ${{ secrets.BOT_GITEA_TOKEN }}
run-id: ${{ gitea.run_id }}
job-name: sonarqube-analysis-dry-run
# - name: JSON clean-up for Custom Quality Gate Check... - name: Post SonarQube Results as Comment
# id: json-cleanup env:
# run: | PR_NUMBER: ${{ needs.check-and-create-pr.outputs.pr_number }}
# echo "Cleaning up quality gate response..." SQ_RESULTS: ${{ steps.convert-json-to-md.outputs.table }}
# echo '${{ steps.quality-gate-check.outputs.quality-gate-result }}' > qg_input.txt QG_STATUS: ${{ needs.quality-gate.outputs.qg_status }}
# sed -E 's/([a-zA-Z0-9_]+):/\\"\1\\":/g; s/:([^",{}\[\]]+)/:"\1"/g' qg_input.txt > qg_raw.json QG_RESULTS: ${{ needs.sonarqube-analysis-dry-run.outputs.qg_results }}
# jq -c '.' qg_raw.json > qg_fixed_json.json RINOA_GITEA_URL: ${{ vars.RINOA_GITEA_URL }}
# echo "qgfixedjson=$(cat qg_fixed_json.json)" >> $GITHUB_OUTPUT GITHUB_REPOSITORY: ${{ github.repository }}
# echo "JSON cleanup complete. BOT_GITEA_TOKEN: ${{ secrets.BOT_GITEA_TOKEN }}
# projstatus=$(jq -r '.projectStatus.status' qg_fixed_json.json) run: |
# caycStatus=$(jq -r '.projectStatus.caycStatus' qg_fixed_json.json) formatted_results=$(echo "${SQ_RESULTS}" | sed 's/\\n/\
# conditions=$(jq -c '.projectStatus.conditions' qg_fixed_json.json) /g')
# echo "projstatus=${projstatus}" >> $GITHUB_OUTPUT payload=$(jq -n \
# echo "caycStatus=${caycStatus}" >> $GITHUB_OUTPUT --arg body "SonarQube analysis results:
# echo "conditions=${conditions}" >> $GITHUB_OUTPUT <br>
# - name: Post SonarQube Results as Comment ${{ env.SQ_RESULTS }}" \
# env: '{ body: $body }')
# 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: |
# formatted_results=$(echo "${SQ_RESULTS}" | sed 's/\\n/\
# /g')
# payload=$(jq -n \
# --arg body "SonarQube analysis results:
# <br>
# ${{ env.SQ_RESULTS }}" \
# '{ body: $body }')
# response=$(curl -s -o response.json -w "%{http_code}" \ response=$(curl -s -o response.json -w "%{http_code}" \
# -X POST \ -X POST \
# -H "Accept: application/json" \ -H "Accept: application/json" \
# -H "Authorization: token ${BOT_GITEA_TOKEN}" \ -H "Authorization: token ${BOT_GITEA_TOKEN}" \
# -H "Content-Type: application/json" \ -H "Content-Type: application/json" \
# -d "$payload" \ -d "$payload" \
# "${RINOA_GITEA_URL}/api/v1/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/reviews") "${RINOA_GITEA_URL}/api/v1/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/reviews")
# - name: Convert JSON to Markdown Table
# id: convert-json-to-md
# uses: buildingcash/json-to-markdown-table-action@v1.1.0
# with:
# json: "${{ steps.json-cleanup.outputs.conditions }}"
# - name: Merge PR in Gitea # - name: Merge PR in Gitea
# uses: prasiman/gocurl@v1 # uses: prasiman/gocurl@v1