diff --git a/.github/workflows/dev-ci.yml b/.github/workflows/dev-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..ec853133ba4d2335eb81e9d95ea0fee11b36fc36 --- /dev/null +++ b/.github/workflows/dev-ci.yml @@ -0,0 +1,37 @@ +name: CI - Development + +on: + push: + branches: + - dev + pull_request: + branches: + - dev + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up JDK 21 (using Zulufx) + uses: actions/setup-java@v2 + with: + java-version: '21' + distribution: 'zulu' + java-package: jdk + architecture: x64 + + - name: Build with Maven + run: mvn clean install + + - name: Run Unit Tests + run: mvn test + + - name: Run Integration Tests + run: mvn verify -P integration-tests + + - name: Run UAT (Karate DSL) + run: mvn test -P uat \ No newline at end of file diff --git a/.github/workflows/production-cd.yml b/.github/workflows/production-cd.yml new file mode 100644 index 0000000000000000000000000000000000000000..1e4a4112ab91d7e9ec6e17148606e5ec28ec732f --- /dev/null +++ b/.github/workflows/production-cd.yml @@ -0,0 +1,53 @@ +name: CI/CD Pipeline for GKE + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Install the gcloud CLI + uses: google-github-actions/setup-gcloud@v2 + with: + project_id: ${{ secrets.GOOGLE_PROJECT }} + service_account_key: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} + export_default_credentials: true + + - name: Authenticate with GCP + uses: google-github-actions/auth@v1 + with: + credentials_json: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} + + - name: Configure Docker + run: | + gcloud auth configure-docker + + - name: Build and Push Docker Image + env: + GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }} + run: | + gcloud auth configure-docker us-central1-docker.pkg.dev + docker build -t us-central1-docker.pkg.dev/$GOOGLE_PROJECT/my-repository/authentication:latest . + docker push us-central1-docker.pkg.dev/$GOOGLE_PROJECT/my-repository/authentication:latest + + - name: Install required components + run: | + gcloud components update + gcloud components install gke-gcloud-auth-plugin + + - name: Deploy to GKE + env: + GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }} + run: | + gcloud container clusters get-credentials safetypin-cluster --region asia-southeast2 + sed -i "s/GOOGLE_PROJECT/$GOOGLE_PROJECT/g" resources.yaml + kubectl apply -f resources.yaml \ No newline at end of file diff --git a/.github/workflows/staging-ci-cd.yml b/.github/workflows/staging-ci-cd.yml new file mode 100644 index 0000000000000000000000000000000000000000..ccc2d24e7f4f9766978055dd6e464be9416947cc --- /dev/null +++ b/.github/workflows/staging-ci-cd.yml @@ -0,0 +1,55 @@ +name: CI/CD Pipeline for Staging + +on: + push: + branches: + - staging + pull_request: + branches: + - staging + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up JDK 21 (using Zulufx) + uses: actions/setup-java@v2 + with: + java-version: '21' + distribution: 'zulu' + java-package: jdk + architecture: x64 + + - name: Build with Maven + run: mvn clean install + + - name: Run Unit Tests + run: mvn test + + - name: Run Regression Tests (JUnit 5, TestContainers) + run: mvn test -P regression-tests + + build-and-deliver: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Install the gcloud CLI + uses: google-github-actions/setup-gcloud@v0 + with: + project_id: ${{ secrets.GOOGLE_PROJECT }} + service_account_key: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} + export_default_credentials: true + + - name: Build and Push Docker Image + env: + GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }} + run: | + gcloud auth configure-docker us-central1-docker.pkg.dev + docker build -t us-central1-docker.pkg.dev/$GOOGLE_PROJECT/my-repository/authentication:latest . + docker push us-central1-docker.pkg.dev/$GOOGLE_PROJECT/my-repository/authentication:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 4e6ecfe337b2ade67d2a287f3c90ca8ab89ed6d1..a5403eff656f15272fcb7e6c9c10de0edac79cd4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,6 @@ RUN mvn clean package -DskipTests # Step 2: Use OpenJDK 21 to run the application FROM openjdk:21-jdk-slim WORKDIR /app -COPY --from=builder /app/target/api-gateway-0.0.1-SNAPSHOT.jar app.jar +COPY --from=builder /app/target/authentication-0.0.1-SNAPSHOT.jar app.jar EXPOSE 8080 CMD ["java", "-jar", "app.jar"]