diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 0f4f3d9ae..cf60d3d2a 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -20,6 +20,7 @@ on: description: 'Version is used to create a git tag when releasing' required: true type: string + default: '' jobs: cleanup: @@ -40,6 +41,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + with: + ref: ${{ inputs.release_version || github.ref }} - name: Update environment variables for .env env: @@ -87,5 +90,5 @@ jobs: - name: Build and bring up containers without cache working-directory: ./marketplace-build run: | - docker compose build --no-cache --build-arg BUILD_ENV=${{ inputs.build_env }} + docker compose build --no-cache --build-arg BUILD_ENV=${{ inputs.build_env }} --build-arg BUILD_VERSION=${{ inputs.release_version }} docker compose up --force-recreate -d diff --git a/.github/workflows/docker-release.yml b/.github/workflows/release-build.yml similarity index 86% rename from .github/workflows/docker-release.yml rename to .github/workflows/release-build.yml index 26a6aa750..a22e97a25 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/release-build.yml @@ -1,4 +1,4 @@ -name: Docker Release +name: Release Build on: push: @@ -19,9 +19,28 @@ env: SERVICE_IMAGE_NAME: marketplace-service jobs: + tagging_source: + name: Create new GH Tag for release + runs-on: self-hosted + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Create release tag + continue-on-error: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git fetch --tags + git push origin :refs/tags/${{ inputs.release_version }} + git tag -d ${{ inputs.release_version }} + git tag -a ${{ inputs.release_version }} -m "Released ${{ inputs.release_version }} by ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + git push origin ${{ inputs.release_version }} build: name: Build Docker images + needs: tagging_source uses: ./.github/workflows/docker-build.yml with: release_version: ${{ inputs.release_version }} @@ -36,17 +55,6 @@ jobs: contents: read steps: - - name: Create release tag - continue-on-error: true - run: | - git config user.name "$(git log -n 1 --pretty=format:%an)" - git config user.email "$(git log -n 1 --pretty=format:%ae)" - git push --delete origin ${{ inputs.release_version }} || true - git tag -d ${{ inputs.release_version }} || true - git commit -a -m "update projects version" - git tag -a ${{ inputs.release_version }} -m "Released ${{ inputs.release_version }} by ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" - git push origin ${{ inputs.release_version }} - - name: Wait for containers to be up and running working-directory: ./marketplace-build run: | diff --git a/marketplace-build/docker-compose.yml b/marketplace-build/docker-compose.yml index 5ba3d718d..4b61cc430 100644 --- a/marketplace-build/docker-compose.yml +++ b/marketplace-build/docker-compose.yml @@ -51,6 +51,8 @@ services: build: context: ../marketplace-service dockerfile: Dockerfile + args: + - BUILD_VERSION=${BUILD_VERSION} ports: - "8080:8080" depends_on: diff --git a/marketplace-service/Dockerfile b/marketplace-service/Dockerfile index 8a963d725..95f00a3c3 100644 --- a/marketplace-service/Dockerfile +++ b/marketplace-service/Dockerfile @@ -11,7 +11,8 @@ WORKDIR /app RUN rm -rf /usr/local/tomcat/webapps/ROOT # Copy the WAR file to the webapps directory in Tomcat -COPY --from=build-api /app/target/marketplace-service-0.0.1-SNAPSHOT.war /usr/local/tomcat/webapps/marketplace-service.war +ARG BUILD_VERSION +COPY --from=build-api /app/target/marketplace-service-${BUILD_VERSION}.war /usr/local/tomcat/webapps/marketplace-service.war # Expose port 8080 EXPOSE 8080