From e1fe1733d02174c38f305272df6f03ca85560b8d Mon Sep 17 00:00:00 2001 From: Anishkulkarni11 <65550281+Anishkulkarni11@users.noreply.github.com> Date: Mon, 28 Aug 2023 14:15:22 +0530 Subject: [PATCH 1/5] Create maven.yml --- .github/workflows/maven.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/maven.yml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 0000000..e5247f5 --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,35 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Java CI with Maven + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -B package --file pom.xml + + # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive + - name: Update dependency graph + uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 From 9557521dcae270c89106510d024c0094d2280956 Mon Sep 17 00:00:00 2001 From: Anishkulkarni11 <65550281+Anishkulkarni11@users.noreply.github.com> Date: Mon, 28 Aug 2023 14:18:32 +0530 Subject: [PATCH 2/5] Update maven.yml --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index e5247f5..1585b03 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -28,7 +28,7 @@ jobs: distribution: 'temurin' cache: maven - name: Build with Maven - run: mvn -B package --file pom.xml + run: mvn clean test # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive - name: Update dependency graph From 849f8a6903f54508ac35848018c53fb195b36bc2 Mon Sep 17 00:00:00 2001 From: Anishkulkarni11 <65550281+Anishkulkarni11@users.noreply.github.com> Date: Mon, 28 Aug 2023 14:27:29 +0530 Subject: [PATCH 3/5] Create Dockerfile --- Dockerfile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a7fdce7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +# Use a base image with Java 17 and Alpine Linux +FROM openjdk:17.0.2-slim + +# Set the working directory +WORKDIR / + +# Expose port 80 +EXPOSE 80 + +# Copy the JAR file into the container +COPY target/spring-petclinic-3.1.0-SNAPSHOT.jar /app.jar + +# Set the entry point to run the application +ENTRYPOINT ["java", "-jar", "/app.jar"] From 5c3c4053bf337b6b7388a4862dd9ab3d7c2a1742 Mon Sep 17 00:00:00 2001 From: Anishkulkarni11 <65550281+Anishkulkarni11@users.noreply.github.com> Date: Mon, 28 Aug 2023 14:29:58 +0530 Subject: [PATCH 4/5] Update maven.yml --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 1585b03..a577ebc 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -28,7 +28,7 @@ jobs: distribution: 'temurin' cache: maven - name: Build with Maven - run: mvn clean test + run: ./mvnw clean package # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive - name: Update dependency graph From 71743c7cea7697fee23ff4018ec1bd9c701d50ec Mon Sep 17 00:00:00 2001 From: Anishkulkarni11 <65550281+Anishkulkarni11@users.noreply.github.com> Date: Mon, 28 Aug 2023 15:30:51 +0530 Subject: [PATCH 5/5] Add or update the App Service deployment workflow configuration from Azure Portal. --- .github/workflows/main_pet123.yml | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/main_pet123.yml diff --git a/.github/workflows/main_pet123.yml b/.github/workflows/main_pet123.yml new file mode 100644 index 0000000..c5c0262 --- /dev/null +++ b/.github/workflows/main_pet123.yml @@ -0,0 +1,51 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +name: Build and deploy container app to Azure Web App - pet123 + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: 'ubuntu-latest' + + steps: + - uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to registry + uses: docker/login-action@v2 + with: + registry: https://index.docker.io/v1/ + username: ${{ secrets.AzureAppService_ContainerUsername_c7864b7e845e4c6883463d1388c9d9cb }} + password: ${{ secrets.AzureAppService_ContainerPassword_b15af5738db5488480ecbd3367145ea3 }} + + - name: Build and push container image to registry + uses: docker/build-push-action@v3 + with: + push: true + tags: index.docker.io/${{ secrets.AzureAppService_ContainerUsername_c7864b7e845e4c6883463d1388c9d9cb }}/pet1:${{ github.sha }} + file: ./Dockerfile + + deploy: + runs-on: ubuntu-latest + needs: build + environment: + name: 'production' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: 'pet123' + slot-name: 'production' + publish-profile: ${{ secrets.AzureAppService_PublishProfile_2e615b003508405795b936400243d16c }} + images: 'index.docker.io/${{ secrets.AzureAppService_ContainerUsername_c7864b7e845e4c6883463d1388c9d9cb }}/pet1:${{ github.sha }}' \ No newline at end of file