From d763f4954afbed7502690dc82ce2af0d6a7f29bd Mon Sep 17 00:00:00 2001 From: Konstantin Zaporozhtsev <51118814+octopusden@users.noreply.github.com> Date: Wed, 7 Jun 2023 16:08:10 +0300 Subject: [PATCH] Use gradle templates (#35) * Switch to build/release gradle templates * Bump template version to v2.1.2 --- .github/workflows/build.yml | 11 +++++++ .github/workflows/release.yml | 56 +++++++---------------------------- 2 files changed, 21 insertions(+), 46 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..ec625e7 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,11 @@ +name: Gradle Compile & UT + +on: [push, pull_request, workflow_dispatch] + +jobs: + run-build-and-deploy: + uses: octopusden/octopus-base/.github/workflows/common-java-gradle-build.yml@v2.1.2 + with: + flow-type: hybrid + java-version: '11' + docker-image: employee-service diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4a9f853..88886ed 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,52 +1,16 @@ -name: Release +name: Gradle Release on: repository_dispatch: - types: [ release ] + types: release jobs: build: - runs-on: ubuntu-latest - environment: Prod - steps: - - uses: actions/checkout@v3 - name: Checkout(switching to commit) - with: - ref: ${{ github.event.client_payload.commit }} - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: '11' - distribution: 'adopt' - cache: 'gradle' - - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@v1 - - name: GitHub Tag Name - run: | - echo "Current version: ${{ github.event.client_payload.project_version }}" - - name: Build with Gradle - run: ./gradlew build dockerBuildImage -x test -Poctopus.github.docker.registry=ghcr.io -Pdocker.registry=docker.io -Pversion=${{ github.event.client_payload.project_version }} --info - env: - BUILD_VERSION: ${{ github.event.client_payload.project_version }} - - name: Publish - run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -Pversion=${{ github.event.client_payload.project_version }} - env: - MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} - ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY }} - ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_PASSPHRASE }} - BUILD_VERSION: ${{ github.event.client_payload.project_version }} - - name: Log in to Docker Hub - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Push to docker registry - run: docker push ghcr.io/octopusden/employee-service:${{ github.event.client_payload.project_version }} - - name: Create Release - uses: marvinpinto/action-automatic-releases@master - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - prerelease: false - automatic_release_tag: v${{ github.event.client_payload.project_version }} + uses: octopusden/octopus-base/.github/workflows/common-java-gradle-release.yml@v2.1.2 + with: + flow-type: hybrid + java-version: '11' + commit-hash: ${{ github.event.client_payload.commit }} + build-version: ${{ github.event.client_payload.project_version }} + docker-image: employee-service + secrets: inherit