Create main.yml #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 | |
| pull_request: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: 'maven' | |
| - name: Compile sysfoo app | |
| run: mvn compile | |
| test: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| strategy: | |
| matrix: | |
| job: [unit-test, sca, sbom] | |
| name: Run ${{ matrix.job }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: 'maven' | |
| - name: Run ${{ matrix.job }} | |
| run: | | |
| if [ "${{ matrix.job }}" == "unit-test" ]; then | |
| mvn clean test | |
| elif [ "${{ matrix.job }}" == "sca" ]; then | |
| sleep 4 | |
| elif [ "${{ matrix.job }}" == "sbom" ]; then | |
| sleep 2 | |
| fi | |
| package: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: 'maven' | |
| - name: Package app | |
| run: mvn package -DskipTests | |
| - name: Archive JAR | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: sysfoo-artifact | |
| path: target/*.jar |