From 0f142231e2d7097c48f698aff0e86d5731bc0ba7 Mon Sep 17 00:00:00 2001 From: saimanaswini-k Date: Thu, 8 Aug 2024 16:01:06 +0530 Subject: [PATCH] Feat : Pull request workflow with github actions --- .github/workflows/build.yml | 4 +- .github/workflows/pull-request.yml | 61 ++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/pull-request.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ac5ced0..65e5919 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,7 +5,7 @@ on: - '*' jobs: - run-test-cases: + Docker build: runs-on: ubuntu-latest steps: - name: Set up JDK 11 @@ -61,5 +61,5 @@ jobs: file: ./Dockerfile push: true tags: | - ${{ vars.DOCKERHUB_USERNAME }}/notification-service:${{ github.ref_name }} + ${{ vars.DOCKERHUB_USERNAME }}/notification_service:${{ github.ref_name }} diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..de42ced --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,61 @@ +name: Build and Deploy +on: + pull_request: + types: [opened, synchronize, reopened, closed] + +jobs: + run-test-cases: + 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: notification-dependency-cache-${{ hashFiles('**/pom.xml') }} + restore-keys: | + notification-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: notification-service + path: service/target/notification-service-1.0.0-dist.zip + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Download build artifact + uses: actions/download-artifact@v3 + with: + name: notification-service + path: ./service/target + + - 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 verify -DskipTests sonar:sonar -Dsonar.projectKey=project-sunbird_sunbird-notification-service -Dsonar.organization=project-sunbird -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/notification-service/notification-service/reports/target/jacoco/jacoco.xml +