From f8246e6b35c13e01e0b287ba523eb5d2ce463a27 Mon Sep 17 00:00:00 2001 From: devopsnishu <103356069+devopsnishu@users.noreply.github.com> Date: Wed, 21 Jun 2023 12:50:30 +0530 Subject: [PATCH 01/17] Update maven.yml --- .github/workflows/maven.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 82af4a9..ef73b60 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -1,7 +1,7 @@ # 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://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven -name: project cicd flow +name: CI-CD on: push: @@ -25,12 +25,4 @@ jobs: - name: Build with Maven run: mvn clean install - - name: Build & push Docker image - uses: mr-smithers-excellent/docker-build-push@v5 - with: - image: javatechie/springboot-images-new - tags: latest - registry: docker.io - dockerfile: Dockerfile - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} \ No newline at end of file + From d27aaf06654177c01c195e7c628f0cd5eb5ab7c6 Mon Sep 17 00:00:00 2001 From: devopsnishu <103356069+devopsnishu@users.noreply.github.com> Date: Wed, 21 Jun 2023 13:44:55 +0530 Subject: [PATCH 02/17] Update maven.yml --- .github/workflows/maven.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index ef73b60..48ecfe8 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -24,5 +24,12 @@ jobs: cache: maven - name: Build with Maven run: mvn clean install - + docker: + uses: devopsnishu/Reusable-Action/.github/workflows/reusable.yml@main + with: + image_name: my-awesome-app + secrets: + DOCKERHUB_USERNAME: ${{secrets.DOCKERHUB_USERNAME}} + DOCKERHUB_PASSWORD: ${{secrets.DOCKERHUB_PASSWORD}} + From 8844760320ce52c58eb34f76437b591e204eb586 Mon Sep 17 00:00:00 2001 From: devopsnishu <103356069+devopsnishu@users.noreply.github.com> Date: Wed, 21 Jun 2023 14:01:00 +0530 Subject: [PATCH 03/17] Update Dockerfile --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index f7cd959..b656eae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM openjdk:8 +WORKDIR /usr/src/app +COPY . . EXPOSE 8080 -ADD target/springboot-images-new.jar springboot-images-new.jar -ENTRYPOINT ["java","-jar","/springboot-images-new.jar"] \ No newline at end of file + From 71f2046ce6d0b21bb2127f6b98219b1c9382ea83 Mon Sep 17 00:00:00 2001 From: devopsnishu <103356069+devopsnishu@users.noreply.github.com> Date: Wed, 21 Jun 2023 14:25:15 +0530 Subject: [PATCH 04/17] Update maven.yml --- .github/workflows/maven.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 48ecfe8..92faa3b 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -24,6 +24,12 @@ jobs: cache: maven - name: Build with Maven run: mvn clean install + - + name: SonarQube Scan + uses: sonarsource/sonarqube-scan-action@master + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} docker: uses: devopsnishu/Reusable-Action/.github/workflows/reusable.yml@main with: From 25e4753d08653eb08fbf597a389ec42a3af8bb90 Mon Sep 17 00:00:00 2001 From: devopsnishu <103356069+devopsnishu@users.noreply.github.com> Date: Wed, 21 Jun 2023 14:31:33 +0530 Subject: [PATCH 05/17] Create sonar-project.properties --- sonar-project.properties | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 sonar-project.properties diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..b3f691d --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,4 @@ +sonar.projectKey=devopsnishu_JAVA +sonar.organization=devopsnishu +sonar.sources=. +# Create a configuration file From 3fe960cedb7c43da96c726adc20da9978de3a867 Mon Sep 17 00:00:00 2001 From: devopsnishu <103356069+devopsnishu@users.noreply.github.com> Date: Wed, 21 Jun 2023 15:24:08 +0530 Subject: [PATCH 06/17] Update Dockerfile --- Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index b656eae..704befd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,4 @@ FROM openjdk:8 -WORKDIR /usr/src/app -COPY . . EXPOSE 8080 - +ADD target/springboot-images-new.jar springboot-images-new.jar +ENTRYPOINT ["java","-jar","/springboot-images-new.jar"] From 8625e10390554785580a0e9b5574bc06b6c0c892 Mon Sep 17 00:00:00 2001 From: devopsnishu <103356069+devopsnishu@users.noreply.github.com> Date: Wed, 21 Jun 2023 15:51:55 +0530 Subject: [PATCH 07/17] Update maven.yml --- .github/workflows/maven.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 92faa3b..3e4f050 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -24,12 +24,7 @@ jobs: cache: maven - name: Build with Maven run: mvn clean install - - - name: SonarQube Scan - uses: sonarsource/sonarqube-scan-action@master - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + docker: uses: devopsnishu/Reusable-Action/.github/workflows/reusable.yml@main with: From 1e9f2f72eca41edabff0ade073252c18096746fb Mon Sep 17 00:00:00 2001 From: devopsnishu <103356069+devopsnishu@users.noreply.github.com> Date: Wed, 21 Jun 2023 16:28:11 +0530 Subject: [PATCH 08/17] Update maven.yml --- .github/workflows/maven.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 3e4f050..34774e6 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -28,6 +28,7 @@ jobs: docker: uses: devopsnishu/Reusable-Action/.github/workflows/reusable.yml@main with: + dockerfile: Dockerfile image_name: my-awesome-app secrets: From 966da71480dfd67b9b3da44e2746cd626927ab30 Mon Sep 17 00:00:00 2001 From: devopsnishu <103356069+devopsnishu@users.noreply.github.com> Date: Wed, 21 Jun 2023 16:35:54 +0530 Subject: [PATCH 09/17] Update maven.yml --- .github/workflows/maven.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 34774e6..1e483a0 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -22,15 +22,18 @@ jobs: java-version: '1.8' distribution: 'adopt' cache: maven + - name: Build with Maven run: mvn clean install - + - name: Unit Tests + run: mvn -B test --file pom.xml docker: uses: devopsnishu/Reusable-Action/.github/workflows/reusable.yml@main with: - dockerfile: Dockerfile + image_name: my-awesome-app - + tags: latest + dockerfile: Dockerfile secrets: DOCKERHUB_USERNAME: ${{secrets.DOCKERHUB_USERNAME}} DOCKERHUB_PASSWORD: ${{secrets.DOCKERHUB_PASSWORD}} From 220aab5bc63575a51878cc05dc3f96b67cba6e1a Mon Sep 17 00:00:00 2001 From: devopsnishu <103356069+devopsnishu@users.noreply.github.com> Date: Thu, 22 Jun 2023 10:25:03 +0530 Subject: [PATCH 10/17] Update maven.yml --- .github/workflows/maven.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 1e483a0..503e171 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -32,8 +32,7 @@ jobs: with: image_name: my-awesome-app - tags: latest - dockerfile: Dockerfile + secrets: DOCKERHUB_USERNAME: ${{secrets.DOCKERHUB_USERNAME}} DOCKERHUB_PASSWORD: ${{secrets.DOCKERHUB_PASSWORD}} From 5c00ec2115014a7cfec2edbfede8be3a62fa31bd Mon Sep 17 00:00:00 2001 From: devopsnishu <103356069+devopsnishu@users.noreply.github.com> Date: Thu, 22 Jun 2023 10:32:34 +0530 Subject: [PATCH 11/17] Update maven.yml --- .github/workflows/maven.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 503e171..4b1019b 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -30,8 +30,8 @@ jobs: docker: uses: devopsnishu/Reusable-Action/.github/workflows/reusable.yml@main with: - - image_name: my-awesome-app + + image_name: Javafile secrets: DOCKERHUB_USERNAME: ${{secrets.DOCKERHUB_USERNAME}} From 862f70515fbd14bde8a1692690a3d81f499e976c Mon Sep 17 00:00:00 2001 From: devopsnishu <103356069+devopsnishu@users.noreply.github.com> Date: Thu, 22 Jun 2023 11:11:01 +0530 Subject: [PATCH 12/17] Update maven.yml --- .github/workflows/maven.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 4b1019b..107034f 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -32,6 +32,7 @@ jobs: with: image_name: Javafile + docker: ./Dockerfile secrets: DOCKERHUB_USERNAME: ${{secrets.DOCKERHUB_USERNAME}} From b1839927b70266e4599a06ca07336e82bb1d426d Mon Sep 17 00:00:00 2001 From: devopsnishu <103356069+devopsnishu@users.noreply.github.com> Date: Thu, 22 Jun 2023 11:47:31 +0530 Subject: [PATCH 13/17] Create Reusable --- .github/workflows/Reusable | 49 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/Reusable diff --git a/.github/workflows/Reusable b/.github/workflows/Reusable new file mode 100644 index 0000000..bffdc56 --- /dev/null +++ b/.github/workflows/Reusable @@ -0,0 +1,49 @@ +name: Docker Image + +on: + workflow_call: + inputs: + image_name: + required: true + type: string + tag: + type: string + secrets: + DOCKERHUB_USERNAME: + required: true + DOCKERHUB_PASSWORD: + required: true + +jobs: + build: + runs-on: ubuntu-latest + + steps: + + - name: Login to the Registry + uses: docker/login-action@v2 + with: + username: ${{secrets.DOCKERHUB_USERNAME}} + password: ${{secrets.DOCKERHUB_PASSWORD}} + - + name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v2 + with: + images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ inputs.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + dockerfile: ./Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + + do-something-else: + runs-on: ubuntu-latest + + steps: + - run: echo "Hello" From 9bb31d33dda30478df9cf3047d7cba3b1ea2bd7c Mon Sep 17 00:00:00 2001 From: devopsnishu <103356069+devopsnishu@users.noreply.github.com> Date: Thu, 22 Jun 2023 11:49:34 +0530 Subject: [PATCH 14/17] Update maven.yml --- .github/workflows/maven.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 107034f..2216ee6 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -28,11 +28,11 @@ jobs: - name: Unit Tests run: mvn -B test --file pom.xml docker: - uses: devopsnishu/Reusable-Action/.github/workflows/reusable.yml@main + uses: devopsnishu/JAVA/.github/workflows/Reusable.yml@master with: image_name: Javafile - docker: ./Dockerfile + secrets: DOCKERHUB_USERNAME: ${{secrets.DOCKERHUB_USERNAME}} From b6e8091b95d7a5cf47cbb420904a8d0158566ddc Mon Sep 17 00:00:00 2001 From: devopsnishu <103356069+devopsnishu@users.noreply.github.com> Date: Thu, 22 Jun 2023 11:52:41 +0530 Subject: [PATCH 15/17] 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 2216ee6..d5c374a 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -31,7 +31,7 @@ jobs: uses: devopsnishu/JAVA/.github/workflows/Reusable.yml@master with: - image_name: Javafile + image_name: Javafile1 secrets: From b3c1536560c2e08a6f5a86a382cc0acc3264a33d Mon Sep 17 00:00:00 2001 From: devopsnishu <103356069+devopsnishu@users.noreply.github.com> Date: Thu, 22 Jun 2023 11:54:08 +0530 Subject: [PATCH 16/17] Delete Reusable --- .github/workflows/Reusable | 49 -------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 .github/workflows/Reusable diff --git a/.github/workflows/Reusable b/.github/workflows/Reusable deleted file mode 100644 index bffdc56..0000000 --- a/.github/workflows/Reusable +++ /dev/null @@ -1,49 +0,0 @@ -name: Docker Image - -on: - workflow_call: - inputs: - image_name: - required: true - type: string - tag: - type: string - secrets: - DOCKERHUB_USERNAME: - required: true - DOCKERHUB_PASSWORD: - required: true - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - - name: Login to the Registry - uses: docker/login-action@v2 - with: - username: ${{secrets.DOCKERHUB_USERNAME}} - password: ${{secrets.DOCKERHUB_PASSWORD}} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v2 - with: - images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ inputs.IMAGE_NAME }} - - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: . - dockerfile: ./Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - - do-something-else: - runs-on: ubuntu-latest - - steps: - - run: echo "Hello" From 0c5a39b27f81820c9b095dde666f991a590d7c5b Mon Sep 17 00:00:00 2001 From: devopsnishu <103356069+devopsnishu@users.noreply.github.com> Date: Thu, 22 Jun 2023 11:56:43 +0530 Subject: [PATCH 17/17] 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 d5c374a..5fc10fd 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -28,7 +28,7 @@ jobs: - name: Unit Tests run: mvn -B test --file pom.xml docker: - uses: devopsnishu/JAVA/.github/workflows/Reusable.yml@master + uses: devopsnishu/Reusable-Action/.github/workflows/reusable.yml@main with: image_name: Javafile1