🔧 fix: update application properties and OpenAPI configuration #10
Workflow file for this run
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: Build and Push Transaction MS | |
| on: | |
| # Only trigger when code is pushed to main (i.e., when PR is merged) | |
| push: | |
| branches: [ main, ms-transaction-deploy ] | |
| workflow_dispatch: | |
| jobs: | |
| # Job 1: Run tests and quality checks | |
| test: | |
| name: Run Tests and Quality Checks | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Step 1: Download repository code | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # Step 2: Install Java 17 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: 'maven' | |
| # Step 3: Check code style with Checkstyle | |
| - name: Run Checkstyle | |
| run: mvn checkstyle:check | |
| # Step 4: Run unit tests with JaCoCo coverage | |
| - name: Run Tests with JaCoCo | |
| run: mvn clean test | |
| # Step 5: Generate coverage report | |
| - name: Generate JaCoCo Report | |
| run: mvn jacoco:report | |
| # Step 6: Check if coverage meets threshold (optional - won't fail build) | |
| - name: Check Code Coverage | |
| run: mvn jacoco:check | |
| continue-on-error: true | |
| # Step 7: Save coverage report as artifact (viewable in GitHub) | |
| - name: Upload Coverage Report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: target/site/jacoco/ | |
| retention-days: 7 | |
| # Job 2: Build JAR and Docker image, push to Docker Hub | |
| build-and-push: | |
| name: Build and Push Docker Image | |
| needs: test # Only runs if tests pass | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Step 1: Download repository code | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # Step 2: Install Java 17 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: 'maven' | |
| # Step 3: Build JAR file (skip tests - already ran in job 1) | |
| - name: Build JAR | |
| run: mvn clean package -DskipTests | |
| # Step 4: Prepare Docker for building | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| # Step 5: Login to Docker Hub | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| # Step 6: Get version from pom.xml | |
| - name: Extract version from pom.xml | |
| id: version | |
| run: | | |
| VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Building version: $VERSION" | |
| # Step 7: Build Docker image and push to Docker Hub | |
| - name: Build and Push Docker Image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: | | |
| ${{ secrets.DOCKERHUB_USERNAME }}/transaction-ms:latest | |
| ${{ secrets.DOCKERHUB_USERNAME }}/transaction-ms:${{ steps.version.outputs.version }} | |
| ${{ secrets.DOCKERHUB_USERNAME }}/transaction-ms:${{ github.sha }} | |
| cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/transaction-ms:buildcache | |
| cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/transaction-ms:buildcache,mode=max | |
| # Step 8: Trigger deployment repo to update EC2 | |
| - name: Trigger Deployment | |
| if: success() | |
| run: | | |
| curl -X POST \ | |
| -H "Accept: application/vnd.github.v3+json" \ | |
| -H "Authorization: token ${{ secrets.DEPLOYMENT_TRIGGER_TOKEN }}" \ | |
| https://api.github.com/repos/${{ secrets.DEPLOYMENT_REPO }}/dispatches \ | |
| -d '{"event_type":"transaction-ms-updated"}' | |
| continue-on-error: true | |
| # Step 9: Show summary | |
| - name: Image Summary | |
| run: | | |
| echo "### Docker Image Published :rocket:" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Image**: ${{ secrets.DOCKERHUB_USERNAME }}/transaction-ms" >> $GITHUB_STEP_SUMMARY | |
| echo "**Tags**:" >> $GITHUB_STEP_SUMMARY | |
| echo "- latest" >> $GITHUB_STEP_SUMMARY | |
| echo "- ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY |