commit 581d24ae2b778cb39d70c78021f7bb6bc5a7ae4c Author: dev1 Date: Mon May 4 15:28:03 2026 +0200 Add: Sonarqube automation template diff --git a/.gitea/workflows/sonarqube.yml b/.gitea/workflows/sonarqube.yml new file mode 100644 index 0000000..b38fb8d --- /dev/null +++ b/.gitea/workflows/sonarqube.yml @@ -0,0 +1,40 @@ +name: SonarQube Analysis + +on: + push: + branches: + - main + +jobs: + sonar: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Define project key + run: | + echo "PROJECT_KEY=${GITHUB_REPOSITORY##*/}" >> "$GITHUB_ENV" + + - name: Create SonarQube project if needed + run: | + curl -s -u "${{ secrets.SONAR_ADMIN_TOKEN }}:" \ + -X POST \ + "http://sonarqube:9000/api/projects/create" \ + --data-urlencode "name=${PROJECT_KEY}" \ + --data-urlencode "project=${PROJECT_KEY}" \ + || true + + - name: Run SonarScanner + run: | + docker run --rm \ + --network dev-platform_default \ + -e SONAR_HOST_URL="http://sonarqube:9000" \ + -e SONAR_TOKEN="${{ secrets.SONAR_ADMIN_TOKEN }}" \ + -v "$PWD:/usr/src" \ + sonarsource/sonar-scanner-cli \ + -Dsonar.projectKey="${PROJECT_KEY}" \ + -Dsonar.projectName="${PROJECT_KEY}" \ + -Dsonar.sources=. \ + -Dsonar.sourceEncoding=UTF-8 \ No newline at end of file