diff --git a/.github/workflows/deploy-and-test-cluster.yml b/.github/workflows/deploy-and-test-cluster.yml deleted file mode 100644 index 28c61c132..000000000 --- a/.github/workflows/deploy-and-test-cluster.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Deploy and Test Cluster - -on: - # push: - # branches: [main] - # paths: - # - 'k8s/**' - # pull_request: - # branches: [main] - # paths: - # - 'k8s/**' - workflow_dispatch: - -jobs: - deploy-and-test-cluster: - runs-on: ubuntu-latest - steps: - - name: Check out the repository - uses: actions/checkout@v2 - - - name: Create k8s Kind Cluster - uses: helm/kind-action@v1 - - - name: Deploy application - run: | - kubectl apply -f k8s/ - - - name: Wait for Pods to be ready - run: | - kubectl wait --for=condition=ready pod -l app=demo-db --timeout=180s - kubectl wait --for=condition=ready pod -l app=petclinic --timeout=180s - diff --git a/.github/workflows/gradle-build.yml b/.github/workflows/gradle-build.yml deleted file mode 100644 index 318c7dd5d..000000000 --- a/.github/workflows/gradle-build.yml +++ /dev/null @@ -1,32 +0,0 @@ -# This workflow will build a Java project with Gradle, and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-java-with-gradle - -name: Java CI with Gradle - -on: - # push: - # branches: [ main ] - # pull_request: - # branches: [ main ] - workflow_dispatch: - -jobs: - build: - - runs-on: ubuntu-latest - strategy: - matrix: - java: [ '17' ] - - steps: - - uses: actions/checkout@v4 - - name: Set up JDK ${{matrix.java}} - uses: actions/setup-java@v4 - with: - java-version: ${{matrix.java}} - distribution: 'adopt' - cache: maven - - name: Setup Gradle - uses: gradle/actions/setup-gradle@v4 - - name: Build with Gradle - run: ./gradlew build diff --git a/.github/workflows/pull-request-pipeline.yml b/.github/workflows/pull-request-pipeline.yml new file mode 100644 index 000000000..7a6cb404d --- /dev/null +++ b/.github/workflows/pull-request-pipeline.yml @@ -0,0 +1,77 @@ +name: Pull request pipeline + +on: + pull_request: + types: + - opened + branches: + - 'main' + +jobs: + build: + 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: Maven install dependencies + run: ./mvnw clean package + + - name: Upload JAR artifact + uses: actions/upload-artifact@v4 + with: + name: grid-capstone + 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/ + + + + diff --git a/.github/workflows/setup-infra-pipeline.yml b/.github/workflows/setup-infra-pipeline.yml new file mode 100644 index 000000000..e36754379 --- /dev/null +++ b/.github/workflows/setup-infra-pipeline.yml @@ -0,0 +1,59 @@ +name: Setup cloud infrastructure + +on: + workflow_dispatch: + push: + branches: + - 'feature-branch' + +jobs: + infrastructure: + runs-on: ubuntu-latest + steps: + - uses: azure/login@v2 + 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: Checkout repository + uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Setting up terraform + uses: hashicorp/setup-terraform@v3 + + + - name: Setup git configuration + run: | + git config --global user.name 'Kacper Piasecki' + git config --global user.email 'k.r.piasecki2@gmail.com' + + - name: Clone git repository of infrastructure + run: | + rm -Rf .git + mkdir cicd + cd cicd + git clone https://x-access-token:${{ secrets.INFRA_GITHUB_TOKEN }}@github.com/Piasecki-grid/grid-capstone-terraform-infra.git + + + - name: Terraform Init + run: | + cd cicd/grid-capstone-terraform-infra + terraform init + + + - name: Terraform Format & Validate + run: | + cd cicd/grid-capstone-terraform-infra + terraform fmt -check + terraform validate + + + - name: Terraform Apply + run: | + cd cicd/grid-capstone-terraform-infra + terraform apply --auto-approve + + +