diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 059a45bd3..168815747 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -6,16 +6,32 @@ on: IMAGE_VERSION_TAG: required: true type: string + DOCKERHUB_USERNAME: + required: true + type: string + PUSH_IMAGES: + required: true + type: boolean + secrets: + DATADOG_API_KEY: + required: true + DOCKERHUB_TOKEN: + required: true jobs: docker-build-server: runs-on: blacksmith name: Server steps: + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ inputs.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push uses: useblacksmith/build-push-action@v1 with: - push: false + push: ${{ inputs.PUSH_IMAGES }} tags: speckle/speckle-server:${{ inputs.IMAGE_VERSION_TAG }} file: ./packages/server/Dockerfile @@ -23,10 +39,15 @@ jobs: runs-on: blacksmith name: Frontend2 steps: + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ inputs.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push uses: useblacksmith/build-push-action@v1 with: - push: false + push: ${{ inputs.PUSH_IMAGES }} tags: speckle/speckle-frontend-2:${{ inputs.IMAGE_VERSION_TAG }} file: ./packages/frontend-2/Dockerfile @@ -34,10 +55,15 @@ jobs: runs-on: blacksmith name: Preview service steps: + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ inputs.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push uses: useblacksmith/build-push-action@v1 with: - push: false + push: ${{ inputs.PUSH_IMAGES }} tags: speckle/speckle-preview-service:${{ inputs.IMAGE_VERSION_TAG }} file: ./packages/preview-service/Dockerfile @@ -45,10 +71,15 @@ jobs: runs-on: blacksmith name: Webhook service steps: + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ inputs.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push uses: useblacksmith/build-push-action@v1 with: - push: false + push: ${{ inputs.PUSH_IMAGES }} tags: speckle/speckle-webhook-service:${{ inputs.IMAGE_VERSION_TAG }} file: ./packages/webhook-service/Dockerfile @@ -56,10 +87,15 @@ jobs: runs-on: blacksmith name: File import service steps: + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ inputs.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push uses: useblacksmith/build-push-action@v1 with: - push: false + push: ${{ inputs.PUSH_IMAGES }} tags: speckle/speckle-fileimport-service:${{ inputs.IMAGE_VERSION_TAG }} file: ./packages/fileimport-service/Dockerfile @@ -67,10 +103,15 @@ jobs: runs-on: blacksmith name: Test deploy util steps: + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ inputs.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push uses: useblacksmith/build-push-action@v1 with: - push: false + push: ${{ inputs.PUSH_IMAGES }} tags: speckle/speckle-test-deployment:${{ inputs.IMAGE_VERSION_TAG }} file: ./utils/test-deployment/Dockerfile @@ -78,10 +119,15 @@ jobs: runs-on: blacksmith name: monitor container steps: + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ inputs.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push uses: useblacksmith/build-push-action@v1 with: - push: false + push: ${{ inputs.PUSH_IMAGES }} tags: speckle/speckle-monitor-deployment:${{ inputs.IMAGE_VERSION_TAG }} file: ./packages/monitor-deployment/Dockerfile @@ -89,9 +135,32 @@ jobs: runs-on: blacksmith name: Docker compose ingress steps: + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ inputs.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push uses: useblacksmith/build-push-action@v1 with: - push: false + push: ${{ inputs.PUSH_IMAGES }} tags: speckle/speckle-docker-compose-ingress:${{ inputs.IMAGE_VERSION_TAG }} file: ./utils/docker-compose-ingress/Dockerfile + + docker-frontend-2-sourcemaps: + runs-on: blacksmith + name: Frontend2 sourcemaps + if: ${{ inputs.PUSH_IMAGES }} + env: + IMAGE_VERSION_TAG: ${{ inputs.IMAGE_VERSION_TAG }} + DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} + SPECKLE_SERVER_PACKAGE: frontend-2 + steps: + - uses: actions/checkout@v4.2.2 + with: + fetch-depth: 0 + - uses: useblacksmith/build-push-action@v1 + with: + setup-only: true + - name: Build and Publish sourcemaps + run: ./.github/workflows/scripts/publish_fe2_sourcemaps.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 962461dc8..342628897 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,10 @@ name: CI Pipeline on: pull_request +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true # other running workflows get cancelled on the same branch + jobs: get-version: outputs: @@ -34,4 +38,6 @@ jobs: uses: ./.github/workflows/builds.yml with: IMAGE_VERSION_TAG: ${{ needs.get-version.outputs.IMAGE_VERSION_TAG }} + DOCKERHUB_USERNAME: 'speckledevops' + PUSH_IMAGES: false secrets: inherit diff --git a/.github/workflows/scripts/publish_fe2_sourcemaps.sh b/.github/workflows/scripts/publish_fe2_sourcemaps.sh new file mode 100644 index 000000000..743e3d689 --- /dev/null +++ b/.github/workflows/scripts/publish_fe2_sourcemaps.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +set -eo pipefail + +echo "๐Ÿท๏ธ Preparing envs" + +GIT_ROOT="$(git rev-parse --show-toplevel)" +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +# shellcheck disable=SC1090,SC1091 +source "${SCRIPT_DIR}/common.sh" + +FE2_DIR_PATH="${FE2_DIR_PATH:-"packages/frontend-2"}" +FE2_DATADOG_SERVICE="${FE2_DATADOG_SERVICE:-"web-app-2"}" +DATADOG_SITE="${DATADOG_SITE:-"datadoghq.eu"}" + +if [[ -z "${DATADOG_API_KEY}" ]]; then + echo "DATADOG_API_KEY is not set" + exit 1 +fi + +echo "๐Ÿ—๏ธ Building prod docker image with sourcemaps enabled" + +export DOCKER_BUILDKIT=1 +docker build --build-arg BUILD_SOURCEMAPS=true --build-arg SPECKLE_SERVER_VERSION="${IMAGE_VERSION_TAG}" --tag "${DOCKER_IMAGE_TAG}:${IMAGE_VERSION_TAG}-sourcemaps" --file "${FE2_DIR_PATH}/Dockerfile" . +container_id=$(docker create "${DOCKER_IMAGE_TAG}:${IMAGE_VERSION_TAG}-sourcemaps") + +echo "๐Ÿงน Cleaning target location and copy sourcemaps into it" + +rm -rf "${GIT_ROOT}/${FE2_DIR_PATH}/.output" +docker cp "$container_id":/speckle-server "${GIT_ROOT}/${FE2_DIR_PATH}/.output" +docker rm "$container_id" + +echo "๐Ÿ†• Publishing sourcemaps" + +pushd "${GIT_ROOT}/${FE2_DIR_PATH}" +DATADOG_SITE="${DATADOG_SITE}" npx --yes @datadog/datadog-ci sourcemaps upload ./.output/public/_nuxt \ +--service="${FE2_DATADOG_SERVICE}" \ +--release-version="${IMAGE_VERSION_TAG}" \ +--minified-path-prefix=/_nuxt +popd + +echo "โœ… Sourcemaps completed." + +# Clean up +rm -rf "${GIT_ROOT}/${FE2_DIR_PATH}/.output"