Feature/GitHub actions cicd #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: PR Checks | |
| on: | |
| pull_request: | |
| branches: [develop, main] | |
| jobs: | |
| detect-changes: | |
| name: Detect Changed Services | |
| runs-on: ubuntu-latest | |
| outputs: | |
| api-gateway: ${{ steps.changes.outputs.api-gateway }} | |
| user-service: ${{ steps.changes.outputs.user-service }} | |
| post-service: ${{ steps.changes.outputs.post-service }} | |
| connections-service: ${{ steps.changes.outputs.connections-service }} | |
| notification-service: ${{ steps.changes.outputs.notification-service }} | |
| uploader-service: ${{ steps.changes.outputs.uploader-service }} | |
| config-server: ${{ steps.changes.outputs.config-server }} | |
| discovery-server: ${{ steps.changes.outputs.discovery-server }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dorny/paths-filter@v3 | |
| id: changes | |
| with: | |
| filters: | | |
| api-gateway: | |
| - 'api-gateway/**' | |
| user-service: | |
| - 'user-service/**' | |
| post-service: | |
| - 'post-service/**' | |
| connections-service: | |
| - 'connections-service/**' | |
| notification-service: | |
| - 'notification-service/**' | |
| uploader-service: | |
| - 'uploader-service/**' | |
| config-server: | |
| - 'config-server/**' | |
| discovery-server: | |
| - 'discovery-server/**' | |
| unit-tests: | |
| name: Unit Tests | |
| runs-on: ubuntu-latest | |
| continue-on-error: true | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'corretto' | |
| cache: maven | |
| - name: Run unit tests | |
| run: | | |
| if [ -f "pom.xml" ]; then | |
| mvn test -DskipIntegrationTests=true || true | |
| else | |
| echo "No root pom.xml found — skipping tests" | |
| fi | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| continue-on-error: true | |
| with: | |
| name: unit-test-results | |
| path: '**/target/surefire-reports/*.xml' | |
| code-coverage: | |
| name: Code Coverage | |
| runs-on: ubuntu-latest | |
| continue-on-error: true | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'corretto' | |
| cache: maven | |
| - name: Run tests with coverage | |
| run: | | |
| if [ -f "pom.xml" ]; then | |
| mvn verify jacoco:report -DskipIntegrationTests=true || true | |
| else | |
| echo "No root pom.xml — skipping coverage" | |
| fi | |
| - name: Upload coverage report | |
| uses: actions/upload-artifact@v4 | |
| continue-on-error: true | |
| with: | |
| name: coverage-report | |
| path: '**/target/site/jacoco/' | |
| security-scan: | |
| name: Security Scan | |
| runs-on: ubuntu-latest | |
| continue-on-error: true | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'corretto' | |
| cache: maven | |
| - name: OWASP Dependency Check | |
| run: | | |
| if [ -f "pom.xml" ]; then | |
| mvn dependency-check:check \ | |
| -DfailBuildOnCVSS=7 \ | |
| -DskipTestScope=true || true | |
| else | |
| echo "No root pom.xml — skipping OWASP" | |
| fi | |
| continue-on-error: true | |
| - name: Upload OWASP report | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| continue-on-error: true | |
| with: | |
| name: owasp-report | |
| path: '**/target/dependency-check-report.html' | |
| code-quality: | |
| name: Code Quality | |
| runs-on: ubuntu-latest | |
| continue-on-error: true | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'corretto' | |
| cache: maven | |
| - name: Checkstyle | |
| run: | | |
| if [ -f "pom.xml" ]; then | |
| mvn checkstyle:check || true | |
| else | |
| echo "No root pom.xml — skipping checkstyle" | |
| fi | |
| continue-on-error: true | |
| - name: SpotBugs | |
| run: | | |
| if [ -f "pom.xml" ]; then | |
| mvn spotbugs:check || true | |
| else | |
| echo "No root pom.xml — skipping spotbugs" | |
| fi | |
| continue-on-error: true |