Reverting back to earlier version.

This commit is contained in:
2024-12-20 18:21:03 -05:00
committed by Trez.One
parent 26b612872e
commit 990cc72ca3
+40 -54
View File
@@ -6,11 +6,12 @@ on:
- main
jobs:
# Job 1: Check if PR exists and create one if the branch is new
check-and-create-pr:
name: Check and Create PR
runs-on: ubuntu-latest
outputs:
pr_created: ${{ steps.cc-pr.outputs.pr_created }}
pr_number: ${{ steps.cc-pr.outputs.pr_index }}
steps:
- name: Checkout Code
@@ -52,14 +53,10 @@ jobs:
exit 1
fi
sonarqube-analysis-dry-run:
name: SonarQube Analysis & Compose Dry-Run
sonarqube-analysis:
name: SonarQube Analysis
runs-on: ubuntu-latest
needs: check-and-create-pr
outputs:
qg_status: ${{ steps.quality-gate.outputs.quality-gate-status }}
qg_results: ${{ steps.quality-gate-check.outputs.quality-gate-result }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
@@ -85,40 +82,13 @@ jobs:
sonar-host-url: ${{ secrets.SONARQUBE_HOST }}
sonar-token: ${{ secrets.SONARQUBE_TOKEN }}
# - name: Generate Ephemeral .env for Dry Run
# run: |
# echo "${{ secrets.RINOA_ENV }}" > .env
# - name: Docker Compose Lint
# id: docker-compose-lint
# uses: https://git.trez.wtf/Trez.One/spin-up-docker-compose-action@v1.3
# with:
# compose-file: "./docker-compose.yml"
# up-flags: --dry-run -d
# pull: true
# pull-opts: --dry-run
# env:
# DOCKER_HOST: tcp://dockerproxy:2375
scan-json-merge-pr:
name: Merge PR if checks pass
runs-on: ubuntu-latest
needs: sonarqube-analysis-dry-run
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: JSON clean-up for Custom Quality Gate Check...
- name: JSON clean-up for proccessing...
id: json-cleanup
env:
QG_RESULTS: ${{ needs.sonarqube-analysis-dry-run.outputs.qg_results }}
run: |
echo "Cleaning up quality gate response..."
echo '${QG_RESULTS}' > qg_input.txt
echo '${{ steps.quality-gate-check.outputs.quality-gate-result }}' > 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)
@@ -126,7 +96,6 @@ jobs:
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
@@ -137,8 +106,7 @@ jobs:
env:
PR_NUMBER: ${{ needs.check-and-create-pr.outputs.pr_number }}
SQ_RESULTS: ${{ steps.convert-json-to-md.outputs.table }}
QG_STATUS: ${{ needs.quality-gate.outputs.qg_status }}
QG_RESULTS: ${{ needs.sonarqube-analysis-dry-run.outputs.qg_results }}
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 }}
@@ -159,19 +127,37 @@ jobs:
-d "$payload" \
"${RINOA_GITEA_URL}/api/v1/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/reviews")
# - name: Merge PR in Gitea
# uses: prasiman/gocurl@v1
# with:
# url: "${{ secrets.GITEA_INSTANCE_URL }}/repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/pulls/${{ needs.check-and-create-pr.outputs.pr_index }}"
# method: "POST"
# headers: '{ "Authorization": "token ${{ secrets.GITEA_API_TOKEN }}", "Content-Type": "application/json" }'
# params: >-
# {
# "Do": "merge",
# "delete_branch_after_merge": true,
# "force_merge": true,
# "merge_when_checks_succeed": true
# }
# Job 3: Merge PR if Quality Gate passes
dry-run-merge-pr:
runs-on: ubuntu-latest
needs: [check-and-create-pr, sonarqube-analysis]
if: needs.sonarqube-analysis.outputs.quality_gate_status == 'PASSED'
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Docker Compose Dry Run
uses: s3i7h/spin-up-docker-compose-action@v1.2
with:
file: docker-compose.yml
pull: true
pull-opts: --dry-run
up: true
up-opts: -d --dry-run
# - name: Confirm Merge
# run: echo "PR has been successfully merged into main."
- name: Merge PR in Gitea
uses: prasiman/gocurl@v1
with:
url: "${{ secrets.GITEA_INSTANCE_URL }}/repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/pulls/${{ needs.check-and-create-pr.outputs.pr_index }}"
method: "POST"
headers: '{ "Authorization": "token ${{ secrets.GITEA_API_TOKEN }}", "Content-Type": "application/json" }'
params: >-
{
"Do": "merge",
"delete_branch_after_merge": true,
"force_merge": true,
"merge_when_checks_succeed": true
}
- name: Confirm Merge
run: echo "PR has been successfully merged into main."