Update technology stack in README #33
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/CD Pipeline | |
| on: | |
| push: | |
| branches: [ "main", "develop" ] | |
| pull_request: | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| build-test: | |
| runs-on: ubuntu-latest | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: '21' | |
| cache: maven | |
| - name: Build and test | |
| run: mvn -B clean verify -Dspring.profiles.active=test | |
| - name: Cache Sonar packages | |
| if: ${{ env.SONAR_TOKEN != '' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }} | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.sonar/cache | |
| key: ${{ runner.os }}-sonar | |
| restore-keys: ${{ runner.os }}-sonar | |
| - name: SonarQube Cloud analysis | |
| if: ${{ env.SONAR_TOKEN != '' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: > | |
| mvn -B org.sonarsource.scanner.maven:sonar-maven-plugin:sonar | |
| -Dspring.profiles.active=test | |
| -Dsonar.qualitygate.wait=true | |
| - name: Upload JAR | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: app-jar | |
| path: target/*.jar | |
| docker: | |
| needs: build-test | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| environment: Test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download JAR | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: app-jar | |
| path: target | |
| - name: Verify JAR exists | |
| run: ls -la target | |
| - name: Login Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Set image tag | |
| run: echo "IMAGE_TAG=${GITHUB_SHA::7}" >> $GITHUB_ENV | |
| - name: Build Docker image | |
| run: | | |
| docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/ordermanagement:latest \ | |
| -t ${{ secrets.DOCKERHUB_USERNAME }}/ordermanagement:${IMAGE_TAG} . | |
| - name: Push image | |
| run: | | |
| docker push ${{ secrets.DOCKERHUB_USERNAME }}/ordermanagement:latest | |
| docker push ${{ secrets.DOCKERHUB_USERNAME }}/ordermanagement:${IMAGE_TAG} |