diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..f4b3419 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,47 @@ +name: Build and Test Spring Boot Application +on: + push: + branches: + - master + - 'feature/*' + pull_request: + branches: + - master + types: [opened, synchronize, reopened] +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Remove previous Java installations + run: sudo apt-get remove -y openjdk-* + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: Verify Java version + run: java -version + - name : list running folder + run: pwd + - name: Build with Maven + working-directory: ./simple-springboot-app + run: mvn clean package -Dmaven.test.skip=true + - name: List files + working-directory: ./simple-springboot-app + run: ls -ls + - name: Build and analyze + working-directory: ./simple-springboot-app + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=blackpandacg_simple-springboot-app -Dsonar.coverage.exclusions="**/*Tests.java" + - name: Build Docker image + run: | + docker build -t shubhamcg1234/simple-springboot-app . + echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin + docker push shubhamcg1234/simple-springboot-app + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + diff --git a/.gitignore b/.gitignore deleted file mode 100644 index ca4e025..0000000 --- a/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -*.iml -.project -.settings/ -.classpath -target/ -.springBeans -.factorypath - diff --git a/README.md b/README.md index dd1e15d..29a1823 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Simple Spring Boot Application - A Quick Start Guide - +making some changes It is an approach to develop spring based application with very less configuration. It provides defaults for code and annotation configuration to quick start new spring projects within no time. diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..f8898b3 --- /dev/null +++ b/dockerfile @@ -0,0 +1,4 @@ +FROM openjdk:11-jre-slim +COPY ./simple-springboot-app/target/*.jar app.jar +EXPOSE 8080 +ENTRYPOINT ["java", "-jar", "/app.jar"] diff --git a/simple-springboot-app/pom.xml b/simple-springboot-app/pom.xml index 671aca5..c52bbe7 100644 --- a/simple-springboot-app/pom.xml +++ b/simple-springboot-app/pom.xml @@ -22,6 +22,8 @@ UTF-8 UTF-8 1.8 + blackpandacg + https://sonarcloud.io @@ -50,9 +52,23 @@ org.springframework.boot spring-boot-maven-plugin + 2.7.0 + + + + org.sonarsource.scanner.maven + sonar-maven-plugin + 3.9.1.2184 + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M5 + + true + - - diff --git a/simple-springboot-app/target/file b/simple-springboot-app/target/file new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/simple-springboot-app/target/file @@ -0,0 +1 @@ +