Create launch #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: CI Pipeline | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Cache Maven dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.m2 | |
| key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
| restore-keys: ${{ runner.os }}-m2 | |
| - name: Run tests | |
| run: ./mvnw clean test | |
| - name: Run linting (Checkstyle) | |
| run: ./mvnw checkstyle:check | |
| - name: Run static analysis (SpotBugs) | |
| run: ./mvnw spotbugs:check | |
| - name: Build application | |
| run: ./mvnw clean package -DskipTests | |
| docker: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build Docker image | |
| run: docker build -t devops-training:latest . | |
| - name: Test Docker image | |
| run: | | |
| docker run -d -p 8080:8080 --name test-app devops-training:latest | |
| sleep 30 | |
| curl -f http://localhost:8080/api/health || exit 1 | |
| docker stop test-app | |
| docker rm test-app |