diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index bb867bc..fc665fe 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -6,8 +6,6 @@ name: Maven Package on: push: branches: [master] - release: - types: [created] jobs: build: @@ -15,18 +13,59 @@ jobs: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v2 - - name: Set up JDK 1.8 + with: + fetch-depth: 0 + - name: Set up JDK 11 uses: actions/setup-java@v1 with: - java-version: 1.8 + java-version: 11 server-id: github # Value of the distributionManagement/repository/id field of the pom.xml settings-path: ${{ github.workspace }} # location for the settings.xml file - name: Build with Maven run: mvn -B package --file pom.xml - - - name: Publish to GitHub Packages Apache Maven - run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml + - name: Analyze with SonarCloud + run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=devopsnishu_github-example-package env: - GITHUB_TOKEN: ${{ github.token }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + - name: API with curl + run: | + curl -u ${{ secrets.SONAR_TOKEN }} https://sonarcloud.io/api/project_badges/measure?project=devopsnishu_github-example-package&metric=coverage + + - name: Test with Maven + run: mvn -B test --file pom.xml + - name: Archive production artifacts + uses: actions/upload-artifact@v2 + with: + name: Java-jar + path: | + src/target/*.jar + src/target/*.zip + + - + name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + - + name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ secrets.DOCKERHUB_USERNAME }}/java + + - + name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + dockerfile: ./Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..264877e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,2 @@ +FROM openjdk:8 +EXPOSE 8080 diff --git a/pom.xml b/pom.xml index d21d08c..422a103 100644 --- a/pom.xml +++ b/pom.xml @@ -6,28 +6,31 @@ github-example-package 1.2-SNAPSHOT jar - + + devopsnishu + https://sonarcloud.io + github - GitHub ManjunathPrabhakar Apache Maven Packages - https://maven.pkg.github.com/ManjunathPrabhakar/github-example-package + GitHub devopsnishu Apache Maven Packages + https://maven.pkg.github.com/devopsnishu/github-example-package - Manjunath Prabhakar - manjunath189@gmail.com - com.github.manjunathprabhakar - https://github.com/ManjunathPrabhakar/github-example-package + devopsnishur + nishuranirai1997@gmail.com + com.github.devopsnishur + https://github.com/devopsnishu/github-example-package - scm:git:git://github.com/ManjunathPrabhakar/github-example-package.git - scm:git:https://github.com/ManjunathPrabhakar/github-example-package.git + scm:git:git://github.com/devopsnishu/github-example-package.git + scm:git:https://github.com/devopsnishu/github-example-package.git - https://github.com/ManjunathPrabhakar/github-example-package + https://github.com/devopsnishu/github-example-package github-example-package @@ -70,4 +73,4 @@ - \ No newline at end of file + diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..6b19c0e --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,9 @@ +sonar.projectKey=devopsnishu_github-example-package +sonar.organization=devopsnishu + +# This is the name and version displayed in the SonarCloud UI. +#sonar.projectName=github-example-package +#sonar.projectVersion=1.0 + +sonar.sources=. + diff --git a/src/pom.xml b/src/pom.xml new file mode 100644 index 0000000..08bee49 --- /dev/null +++ b/src/pom.xml @@ -0,0 +1,80 @@ + + + 4.0.0 + + org.example + artifactId>parent + ${revision} + + + src + jar + Java-jar + + devopsnishu + https://sonarcloud.io + + + + github + GitHub devopsnishu Apache Maven Packages + https://maven.pkg.github.com/devopsnishu/github-example-package + + + + + devopsnishur + nishuranirai1997@gmail.com + com.github.devopsnishur + https://github.com/devopsnishu/github-example-package + + + + + scm:git:git://github.com/devopsnishu/github-example-package.git + scm:git:https://github.com/devopsnishu/github-example-package.git + + https://github.com/devopsnishu/github-example-package + github-example-package + + + + + + + + org.apache.maven.plugins + maven-plugin-plugin + 3.6.0 + + + true + + + + org.apache.maven.plugins + maven-site-plugin + 3.9.1 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 8 + 8 + + + + + org.apache.maven.plugins + maven-release-plugin + 3.0.0-M1 + + + + +