From 396ebcb2fb09d5b62f4aa3ecc5704df1507727ef Mon Sep 17 00:00:00 2001 From: saimanaswini-k Date: Thu, 8 Aug 2024 14:58:49 +0530 Subject: [PATCH 1/3] Feat : Github actions for docker build --- .github/workflows/build.yml | 69 +++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..117f8337 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,69 @@ +name: Build and Deploy +on: + push: + tags: + - '*' + branches: + - master + - release-* + +jobs: + test-docker-build: + runs-on: ubuntu-latest + steps: + - name: Set up JDK 11 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '11' + + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Restore Maven cache + uses: actions/cache@v3 + with: + path: ~/.m2 + key: groups-dependency-cache-${{ hashFiles('**/pom.xml') }} + restore-keys: | + groups-dependency-cache- + + - name: Build and Run test cases + run: mvn clean install + + - name: Save the build artifact + run: mvn -f service/pom.xml play2:dist + + - name: Store build artifact + uses: actions/upload-artifact@v3 + with: + name: group-service + path: service/target/group-service-1.0.0-dist.zip + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Download build artifact + uses: actions/download-artifact@v3 + with: + name: group-service + path: ./service/target + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and Push Docker Image + uses: docker/build-push-action@v5 + with: + context: ./service/target + file: ./Dockerfile + push: true + tags: | + ${{ vars.DOCKERHUB_USERNAME }}/groups_service:${{ github.ref_name }} + + From 857f3ef0b28bf03245454547f779d151298b2316 Mon Sep 17 00:00:00 2001 From: saimanaswini-k Date: Fri, 9 Aug 2024 15:21:39 +0530 Subject: [PATCH 2/3] "Feat : Workflow for github actions" --- .github/workflows/build.yml | 19 ++++++++++++++++++- .github/workflows/pull-request.yml | 18 ++++++++---------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 117f8337..c8d872e9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,7 @@ on: - release-* jobs: - test-docker-build: + Docker-build: runs-on: ubuntu-latest steps: - name: Set up JDK 11 @@ -65,5 +65,22 @@ jobs: push: true tags: | ${{ vars.DOCKERHUB_USERNAME }}/groups_service:${{ github.ref_name }} + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + + - name: Run SonarQube analysis + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: | + mvn -B verify -DskipTests org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \ + -Dsonar.projectKey=Sunbird-Lern_groups-service \ + -Dsonar.organization=sunbird-lern \ + -Dsonar.host.url=https://sonarcloud.io \ + -Dsonar.coverage.exclusions=**/cassandra-utils/**,**/platform-cache/**,**/sb-actor/**,**/sb-telemetry-utils/**,**/sb-utils/**,**/models/**,**/bean/*,**/sb-common/** \ + -Dsonar.coverage.jacoco.xmlReportPaths=/home/runner/work/groups-service/groups-service/reports/target/jacoco/jacoco.xml diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 3badaf38..b9e70563 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,17 +1,11 @@ name: Pull Request Analysis on: - push: - branches: - - master - - release-* pull_request: - types: - - opened - - synchronize + types: [opened, synchronize] jobs: - run-test-cases: + Run-test-cases: runs-on: ubuntu-latest steps: - name: Set up JDK 11 @@ -56,10 +50,14 @@ jobs: with: distribution: 'temurin' java-version: '17' - - name: Run SonarQube analysis env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: | - mvn -B verify -DskipTests org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=Sunbird-Lern_groups-service -Dsonar.organization=sunbird-lern -Dsonar.host.url=https://sonarcloud.io -Dsonar.coverage.exclusions=**/cassandra-utils/**,**/platform-cache/**,**/sb-actor/**,**/sb-telemetry-utils/**,**/sb-utils/**,**/models/**,**/bean/*,**/sb-common/** -Dsonar.coverage.jacoco.xmlReportPaths=/home/runner/work/groups-service/groups-service/reports/target/jacoco/jacoco.xml \ No newline at end of file + mvn -B verify -DskipTests org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \ + -Dsonar.projectKey=Sunbird-Lern_groups-service \ + -Dsonar.organization=sunbird-lern \ + -Dsonar.host.url=https://sonarcloud.io \ + -Dsonar.coverage.exclusions=**/cassandra-utils/**,**/platform-cache/**,**/sb-actor/**,**/sb-telemetry-utils/**,**/sb-utils/**,**/models/**,**/bean/*,**/sb-common/** \ + -Dsonar.coverage.jacoco.xmlReportPaths=/home/runner/work/groups-service/groups-service/reports/target/jacoco/jacoco.xml \ No newline at end of file From 1a6c61d957593fe4737c931ece4b3d05e611182e Mon Sep 17 00:00:00 2001 From: Manaswini <143373040+saimanaswini-k@users.noreply.github.com> Date: Fri, 9 Aug 2024 15:34:33 +0530 Subject: [PATCH 3/3] Feat : Workflow for github actions --- .github/workflows/pull-request.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index b9e70563..0e011d62 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,5 +1,4 @@ name: Pull Request Analysis - on: pull_request: types: [opened, synchronize] @@ -60,4 +59,4 @@ jobs: -Dsonar.organization=sunbird-lern \ -Dsonar.host.url=https://sonarcloud.io \ -Dsonar.coverage.exclusions=**/cassandra-utils/**,**/platform-cache/**,**/sb-actor/**,**/sb-telemetry-utils/**,**/sb-utils/**,**/models/**,**/bean/*,**/sb-common/** \ - -Dsonar.coverage.jacoco.xmlReportPaths=/home/runner/work/groups-service/groups-service/reports/target/jacoco/jacoco.xml \ No newline at end of file + -Dsonar.coverage.jacoco.xmlReportPaths=/home/runner/work/groups-service/groups-service/reports/target/jacoco/jacoco.xml