From 9218e93fdebedeba813ed0200639468a9b29acee Mon Sep 17 00:00:00 2001 From: Piasecki-grid Date: Thu, 27 Mar 2025 22:51:27 +0100 Subject: [PATCH] Final pipeline check --- .github/workflows/maven-build.yml | 89 +++++++++++++++++++------------ 1 file changed, 54 insertions(+), 35 deletions(-) diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml index 455b9307d..88a1666de 100644 --- a/.github/workflows/maven-build.yml +++ b/.github/workflows/maven-build.yml @@ -2,6 +2,9 @@ name: Successfull merge pipeline on: workflow_dispatch: + push: + branches: + - main jobs: build: @@ -11,13 +14,7 @@ jobs: java: [ '17' ] steps: - - name: Install kubectl - uses: azure/setup-kubectl@v4 - with: - version: 'v1.29.0' - id: install - - uses: actions/checkout@v4 name: Checkout code @@ -32,50 +29,70 @@ jobs: run: chmod a+x mvnw - name: Maven install dependencies - run: ./mvnw clean install package + run: ./mvnw clean package - # - name: Upload JAR artifact - # uses: actions/upload-artifact@4 - # with: - # name: grid-capstone - # path: ./target/*.jar - - - - # - name: Login to ACR - # uses: docker/login-action@v3 - # with: - - # registry: ${{ vars.ACR_NAME }}.azurecr.io - # username: ${{ secrets.AZURE_CLIENT_ID }} - # password: ${{ secrets.AZURE_CLIENT_SECRET }} - - - - uses: azure/login@v2 - name: Azure Login + - name: Upload JAR artifact + uses: actions/upload-artifact@v4 with: - creds: '{"clientId":"${{ secrets.AZURE_CLIENT_ID }}","clientSecret":"${{ secrets.AZURE_CLIENT_SECRET }}","subscriptionId":"${{ secrets.AZURE_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.AZURE_TENANT_ID }}"}' + name: app-protector + path: ./target/*.jar + + + test: + runs-on: ubuntu-latest + strategy: + matrix: + java: [ '17' ] + + steps: + - uses: actions/checkout@v4 + name: Checkout code + + - name: Set up JDK ${{matrix.java}} + uses: actions/setup-java@v4 + with: + java-version: ${{matrix.java}} + distribution: 'temurin' + cache: maven + + - name: Add executable permissions + run: chmod a+x mvnw + + - name: Run tests + run: ./mvnw test + + - name: Generate HTML report + run: ./mvnw surefire-report:report + + + - name: Upload test results + uses: actions/upload-artifact@v4 + with: + name: test-reports + path: target/site/ + + + + docker: + needs: [build, test] + runs-on: ubuntu-latest + steps: - name: Docker Build and push run: | az acr login --name ${{ vars.ACR_NAME }} docker build -t ${{ vars.ACR_NAME }}.azurecr.io/grid-capstone:${{ github.sha }} . docker push ${{ vars.ACR_NAME }}.azurecr.io/grid-capstone:${{ github.sha }} - - name: Getting access to the cluster - run: | - az aks get-credentials --resource-group grid-capstone --name dev-grid-cluster --admin --overwrite-existing - kubectl get pods - kubectl get nodes - deploy: - needs: build + needs: [build, test, docker] runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 with: token: ${{ secrets.GITHUB_TOKEN }} + - name: Automatic deployment run: | git config --global user.name 'Kacper Piasecki' @@ -89,6 +106,7 @@ jobs: git add . git commit -m "Kubernetes manifests file update: $(date)" git push + - name: Install kubectl uses: azure/setup-kubectl@v4 with: @@ -99,7 +117,8 @@ jobs: name: Azure Login with: creds: '{"clientId":"${{ secrets.AZURE_CLIENT_ID }}","clientSecret":"${{ secrets.AZURE_CLIENT_SECRET }}","subscriptionId":"${{ secrets.AZURE_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.AZURE_TENANT_ID }}"}' - - name: Getting access to the cluster + + - name: Deploy new version of an image to the cluster run: | az aks get-credentials --resource-group grid-capstone --name dev-grid-cluster --admin --overwrite-existing kubectl apply -f ./cicd/grid-capstone-k8s-manifests