diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml new file mode 100644 index 0000000..95d38e1 --- /dev/null +++ b/.github/workflows/dev.yml @@ -0,0 +1,78 @@ +name: Java CI with Maven + +on: + push: + branches: [ dev ] + pull_request: + branches: [ dev ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'adopt' + cache: maven + + - name: Code check + uses: dbelyaev/action-checkstyle@v0.5.1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-pr-review + level: warning + + - name: Build with Maven + run: | + mvn -B package --file pom.xml + mkdir artifacts && cp target/*.jar artifacts + cd artifacts && ls + + - name: Save artifact + uses: actions/upload-artifact@v2 + with: + name: github-actions-artifact + path: artifacts + + - name: Upload artificat + uses: actions/upload-artifact@v2 + with: + name: sample.jar + path: target/*.jar + + Publish: + needs: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: '11' + + - name: Update version + run: mvn -B versions:set -DnewVersion=v${{github.run_number}} -DgenerateBackupPoms=false + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Download artifact + uses: actions/download-artifact@v2 + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: shydrate/demo-app:v${{github.run_number}} diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index e00bb92..b4c1d9a 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -4,10 +4,10 @@ name: Java CI with Maven on: - push: - branches: [ master ] +# push: +# branches: [ dev, qa, master ] pull_request: - branches: [ master ] + branches: [ master, qa ] jobs: build: @@ -22,13 +22,60 @@ jobs: java-version: '11' distribution: 'adopt' cache: maven + + - name: Code check + uses: dbelyaev/action-checkstyle@v0.5.1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-pr-review + level: warning + - name: Build with Maven run: | mvn -B package --file pom.xml mkdir artifacts && cp target/*.jar artifacts cd artifacts && ls + - name: Save artifact uses: actions/upload-artifact@v2 with: name: github-actions-artifact path: artifacts + + - name: Upload artificat + uses: actions/upload-artifact@v2 + with: + name: sample.jar + path: target/*.jar + + Publish: + needs: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: '11' + + - name: Update version + run: mvn -B versions:set -DnewVersion=v${{github.run_number}} -DgenerateBackupPoms=false + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Download artifact + uses: actions/download-artifact@v2 + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: shydrate/demo-app:v${{github.run_number}} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fc435ff --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM tomcat +#USER root +ADD sample.jar sample.jar +EXPOSE 80 +EXPOSE 8080 + +ENTRYPOINT [ "java", "-DskipTests", "-jar", "sample.jar", "-Xmx256m"]