Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat : Github actions for docker build #194

Open
wants to merge 3 commits into
base: release-7.0.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Build and Deploy
on:
push:
tags:
- '*'
branches:
- master
- release-*

jobs:
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 }}

- 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


19 changes: 8 additions & 11 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
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
Expand Down Expand Up @@ -56,10 +49,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
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
Loading