DTS -49898 complete swagger doc #578
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: API_CI_Workflow # Define the name of the workflows | |
| # Define when the workflow should trigger | |
| on: | |
| pull_request: | |
| types: | |
| - labeled # Trigger when a label is added | |
| - unlabeled # Trigger when a label is removed | |
| - synchronize # Trigger when commits are pushed to the PR | |
| - opened # Trigger when a PR is opened | |
| - edited # Trigger when a PR title or description is edited | |
| - ready_for_review # Trigger when a draft PR is marked as ready | |
| - reopened # Trigger when a closed PR is reopened | |
| - unlocked # Trigger when a locked PR is unlocked | |
| branches: [master, develop, qa-master] # Apply to these branches | |
| pull_request_review: | |
| types: [edited, dismissed] # Trigger when a review is edited or dismissed | |
| branches: [master, develop, qa-master] | |
| workflow_dispatch: # Allow manual triggering of the workflow | |
| # Define environment variables | |
| env: | |
| GITHUB_HEAD_NAME: $GITHUB_HEAD_REF # Store the head branch name | |
| sonartoken: ${{ secrets.SONARQUBE_TOKEN }} # Secret for SonarQube authentication | |
| sonarurl: ${{ secrets.SONARURL }} # SonarQube URL stored in secrets | |
| #MAVEN_GH_TOKEN: ${{ secrets.MAVEN_TOKEN }} # Use the maven_token for authentication | |
| jobs: | |
| # ✅ knowhow-api Build & SonarQube Analysis | |
| api_ci: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v2 | |
| - name: Set Up Java | |
| uses: actions/setup-java@v2 | |
| with: | |
| distribution: "adopt" | |
| java-version: "17" | |
| - name: Cache Maven packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.m2/repository | |
| key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-maven- | |
| # ✅ Configure Maven to use GitHub Package Registry for knowhow-ai-gateway-client | |
| - name: Configure Maven to use GitHub Packages | |
| run: | | |
| mkdir -p ~/.m2 | |
| cat > ~/.m2/settings.xml <<EOF | |
| <settings> | |
| <servers> | |
| <server> | |
| <id>github</id> | |
| <username>${{ github.actor }}</username> | |
| <password>${{ secrets.MAVEN_TOKEN }}</password> | |
| </server> | |
| </servers> | |
| <profiles> | |
| <profile> | |
| <id>github</id> | |
| <repositories> | |
| <repository> | |
| <id>github</id> | |
| <url>https://maven.pkg.github.com/PublicisSapient/knowhow-ai-gateway-client</url> | |
| </repository> | |
| </repositories> | |
| </profile> | |
| </profiles> | |
| <activeProfiles> | |
| <activeProfile>github</activeProfile> | |
| </activeProfiles> | |
| </settings> | |
| EOF | |
| # ✅ Clone & Build knowhow-common dependency | |
| - name: Clone & Build knowhow-common dependency | |
| run: | | |
| SOURCE_BRANCH="${{ github.head_ref }}" | |
| TARGET_BRANCH="${{ github.event.pull_request.base.ref }}" | |
| echo "Checking if branch '$SOURCE_BRANCH' exists in knowhow-common repo..." | |
| if git ls-remote --heads https://github.com/PublicisSapient/knowhow-common.git $SOURCE_BRANCH | grep $SOURCE_BRANCH; then | |
| BRANCH_TO_CLONE=$SOURCE_BRANCH | |
| else | |
| echo "Branch '$SOURCE_BRANCH' not found. Falling back to target branch '$TARGET_BRANCH'." | |
| BRANCH_TO_CLONE=$TARGET_BRANCH | |
| fi | |
| git clone --branch $BRANCH_TO_CLONE https://github.com/PublicisSapient/knowhow-common.git | |
| cd knowhow-common | |
| mvn clean install -Ddockerfile.skip=true -X | |
| # ✅ Get common version using Maven Help Plugin | |
| - name: Get common version using Maven Help Plugin | |
| run: | | |
| cd knowhow-common | |
| COMMON_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | |
| echo "COMMON_VERSION=$COMMON_VERSION" | |
| echo "COMMON_VERSION=$COMMON_VERSION" >> $GITHUB_ENV | |
| # ✅ Updating the common version in api projects | |
| - name: Updating the common version in api project | |
| run: | | |
| mvn versions:use-dep-version \ | |
| -Dincludes=com.publicissapient.kpidashboard:common \ | |
| -DdepVersion=$COMMON_VERSION \ | |
| -DforceVersion=true | |
| # ✅ Code Formatting Check (Spotless) | |
| - name: Code Formatting Check | |
| run: mvn spotless:check | |
| # ✅ Build & Test knowhow-api with both dependencies: common + ai-gateway-client | |
| - name: Build & Test knowhow-api | |
| run: mvn clean install -Ddockerfile.skip=true | |
| # ✅ SonarQube Analysis - knowhow-api | |
| - name: SonarQube Analysis - knowhow-api | |
| run: | | |
| mvn sonar:sonar -Dsonar.projectKey=ENGINEERING.KPIDASHBOARD.CUSTOMAPI \ | |
| -Dsonar.projectName=ENGINEERING.KPIDASHBOARD.CUSTOMAPI \ | |
| -Dsonar.branch.name=${{ env.GITHUB_HEAD_NAME }} \ | |
| -Dsonar.host.url=${{ secrets.SONARQUBE_HOST }} \ | |
| -Dsonar.login=${{ secrets.SONARQUBE_TOKEN }} -f pom.xml | |
| # ✅ Check SonarQube Quality Gate - knowhow-api | |
| - name: Check SonarQube Quality Gate - knowhow-api | |
| run: | | |
| chmod +x SonarQG.sh | |
| ./SonarQG.sh ./target/sonar/report-task.txt | |
| # ✅ Final Job to Ensure Completions | |
| GitHub_CI_Complete: | |
| needs: [api_ci] | |
| if: always() | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| steps: | |
| - name: Check Job Status | |
| run: | | |
| if [[ "${{ needs.api_ci.result }}" == "failure" || \ | |
| "${{ needs.api_ci.result }}" == "cancelled" ]]; then | |
| echo "❌ One or more jobs failed or were cancelled. Failing CI." | |
| exit 1 | |
| else | |
| echo "✅ All relevant jobs have passed." | |
| fi |