From aae0316128415c8a40343224fb1f7ef1c1540acd Mon Sep 17 00:00:00 2001 From: Om Mishra <32200996+mishraomp@users.noreply.github.com> Date: Tue, 20 Aug 2024 14:25:30 -0700 Subject: [PATCH] feat: making pom version aligned. (#83) * making pom version aligned. * fix Dockerfile * Add build step to merge --- .github/workflows/merge.yml | 48 +++++++++++++++++++++++------------ .github/workflows/pr-open.yml | 3 ++- Dockerfile | 6 +++++ 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index c55b829..f930eae 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -61,26 +61,42 @@ jobs: name: ${{ steps.changelog.outputs.tag }} body: ${{ steps.changelog.outputs.clean_changelog }} - - name: Tag Docker Image for app container - uses: shrink/actions-docker-registry-tag@v4 - if: ${{ steps.changelog.outputs.version != '' }} - with: - registry: ghcr.io - repository: ${{ github.repository }}/nr-oracle-service - target: ${{ needs.vars.outputs.pr }} - tags: ${{ steps.changelog.outputs.version }} - - name: Tag Docker Image for init container - uses: shrink/actions-docker-registry-tag@v4 - if: ${{ steps.changelog.outputs.version != '' }} + builds: + name: Builds + needs: semantic-release + runs-on: ubuntu-22.04 + permissions: + packages: write + strategy: + matrix: + package: [ nr-oracle-service, nr-oracle-service-init ] + include: + - package: nr-oracle-service + build_file: Dockerfile + build_context: . + triggers: ('src/' 'pom.xml') + - package: nr-oracle-service-init + build_file: Dockerfile.certs + build_context: . + triggers: ('get_certs.sh' 'Dockerfile.certs') + + + steps: + - uses: actions/checkout@v4 + - uses: bcgov-nr/action-builder-ghcr@v2.0.2 with: - registry: ghcr.io - repository: ${{ github.repository }}/nr-oracle-service-init - target: ${{ needs.vars.outputs.pr }} - tags: ${{ steps.changelog.outputs.version }} + package: ${{ matrix.package }} + tag: ${{ needs.semantic-release.outputs.tag }} + token: ${{ secrets.GITHUB_TOKEN }} + build_file: ${{ matrix.build_file }} + build_context: ${{ matrix.build_context }} + triggers: ${{ matrix.triggers }} + build_args: | + APP_VERSION=${{ needs.semantic-release.outputs.tag }} helm-release: runs-on: ubuntu-22.04 - needs: [semantic-release] + needs: [builds,semantic-release] if: ${{ needs.semantic-release.outputs.version != '' }} steps: - name: Checkout diff --git a/.github/workflows/pr-open.yml b/.github/workflows/pr-open.yml index e7bcf3d..b59f6cc 100644 --- a/.github/workflows/pr-open.yml +++ b/.github/workflows/pr-open.yml @@ -40,7 +40,8 @@ jobs: build_file: ${{ matrix.build_file }} build_context: ${{ matrix.build_context }} triggers: ${{ matrix.triggers }} - + build_args: | + APP_VERSION=${{ github.event.number }} deploys: diff --git a/Dockerfile b/Dockerfile index 2a7c288..83ed954 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,6 @@ FROM quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-21 AS build +# Receiving app version +ARG APP_VERSION=0.0.1 COPY --chown=quarkus:quarkus mvnw /code/mvnw COPY --chown=quarkus:quarkus .mvn /code/.mvn COPY --chown=quarkus:quarkus pom.xml /code/ @@ -7,6 +9,10 @@ WORKDIR /code RUN chmod +x mvnw RUN ./mvnw -B org.apache.maven.plugins:maven-dependency-plugin:3.1.2:go-offline COPY src /code/src + +RUN ./mvnw versions:set -DnewVersion=${APP_VERSION} -f pom.xml -DskipTests -Dtests.skip=true -Dskip.unit.tests=true && \ + ./mvnw versions:commit -f pom.xml -DskipTests -Dtests.skip=true -Dskip.unit.tests=true + RUN ./mvnw package -Pnative -DskipTests #RUN ./mvnw package -DskipTests for JVM mode HEALTHCHECK --interval=300s --timeout=30s CMD ./mvnw --version || exit 1