CI: fix triggers/conditions; make Sonar non-blocking
Some checks failed
CI / skip-ci-check (pull_request) Successful in 1m17s
CI / lint-and-test (pull_request) Successful in 1m22s
CI / ansible-validation (pull_request) Failing after 2m51s
CI / secret-scanning (pull_request) Successful in 1m19s
CI / dependency-scan (pull_request) Successful in 1m24s
CI / sast-scan (pull_request) Successful in 2m42s
CI / license-check (pull_request) Failing after 1m23s
CI / vault-check (pull_request) Failing after 2m17s
CI / playbook-test (pull_request) Failing after 2m23s
CI / container-scan (pull_request) Successful in 1m52s
CI / sonar-analysis (pull_request) Failing after 1m16s
CI / workflow-summary (pull_request) Successful in 1m17s

This commit is contained in:
ilia 2026-01-01 13:03:47 -05:00
parent b69284f1c4
commit e0996642bc

View File

@ -1,7 +1,7 @@
---
name: CI
"on":
on:
push:
branches: [master]
pull_request:
@ -62,10 +62,8 @@ jobs:
lint-and-test:
needs: skip-ci-check
if: needs.skip-ci-check.outputs.should-skip != '1'
runs-on: ubuntu-latest
# Skip push events for non-master branches (they'll be covered by PR events)
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/master'
if: needs.skip-ci-check.outputs.should-skip != '1' && (github.event_name == 'pull_request' || github.ref == 'refs/heads/master')
container:
image: node:20-bullseye
steps:
@ -84,10 +82,8 @@ jobs:
ansible-validation:
needs: skip-ci-check
if: needs.skip-ci-check.outputs.should-skip != '1'
runs-on: ubuntu-latest
# Skip push events for non-master branches (they'll be covered by PR events)
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/master'
if: needs.skip-ci-check.outputs.should-skip != '1' && (github.event_name == 'pull_request' || github.ref == 'refs/heads/master')
container:
image: ubuntu:22.04
steps:
@ -440,7 +436,7 @@ jobs:
sonar-analysis:
needs: skip-ci-check
if: needs.skip-ci-check.outputs.should-skip != '1'
if: needs.skip-ci-check.outputs.should-skip != '1' && (github.event_name == 'pull_request' || github.ref == 'refs/heads/master')
runs-on: ubuntu-latest
container:
image: ubuntu:22.04
@ -534,9 +530,8 @@ jobs:
run: |
echo "Checking SonarQube connectivity..."
if [ -z "$SONAR_HOST_URL" ] || [ -z "$SONAR_TOKEN" ]; then
echo "❌ ERROR: SONAR_HOST_URL or SONAR_TOKEN secrets are not set!"
echo "Please configure them in: Repository Settings → Actions → Secrets"
exit 1
echo "⚠️ Skipping SonarQube analysis: SONAR_HOST_URL or SONAR_TOKEN secrets are not set."
exit 0
fi
echo "✓ Secrets are configured"
echo "SonarQube URL: ${SONAR_HOST_URL}"
@ -544,12 +539,17 @@ jobs:
if curl -f -s -o /dev/null -w "%{http_code}" "${SONAR_HOST_URL}/api/system/status" | grep -q "200"; then
echo "✓ SonarQube server is reachable"
else
echo "⚠️ Warning: Could not verify SonarQube server connectivity"
echo "⚠️ Warning: Could not verify SonarQube server connectivity (continuing anyway)"
fi
- name: Run SonarScanner
run: |
echo "Starting SonarQube analysis..."
if [ -z "$SONAR_HOST_URL" ] || [ -z "$SONAR_TOKEN" ]; then
echo "Skipping SonarQube analysis: secrets not set."
exit 0
fi
if ! sonar-scanner \
-Dsonar.projectKey=ansible \
-Dsonar.sources=. \
@ -570,7 +570,8 @@ jobs:
echo " → Grant this permission in SonarQube user settings"
echo ""
echo "Check SonarQube logs for more details."
exit 1
# Do not fail CI on Sonar auth/project setup issues.
exit 0
fi
continue-on-error: true