ci: add GitHub Actions CI/CD pipeline #1
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 | |
| 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: mvn test -DskipIntegrationTests=true | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: unit-test-results | |
| path: '**/target/surefire-reports/*.xml' | |
| code-coverage: | |
| name: Code Coverage | |
| runs-on: ubuntu-latest | |
| needs: unit-tests | |
| 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: mvn verify jacoco:report -DskipIntegrationTests=true | |
| - name: Upload coverage report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: '**/target/site/jacoco/' | |
| security-scan: | |
| name: Security Scan | |
| runs-on: ubuntu-latest | |
| 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: mvn dependency-check:check -DfailBuildOnCVSS=7 -DskipTestScope=true | |
| continue-on-error: true | |
| - name: Upload OWASP report | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: owasp-report | |
| path: '**/target/dependency-check-report.html' | |
| code-quality: | |
| name: Code Quality | |
| runs-on: ubuntu-latest | |
| 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: mvn checkstyle:check | |
| continue-on-error: true | |
| - name: SpotBugs | |
| run: mvn spotbugs:check | |
| continue-on-error: true |