# CI Build Template
.build:
    script:
        - '[ -z "$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" ] && BRANCH=$CI_COMMIT_BRANCH || BRANCH=$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME'
        - echo "Building branch -- ${BRANCH}"
        - NAME="${REGISTRY_URL}/${PROJECT_NAME}/${SERVICE_NAME}"
        - docker build -t ${NAME}:${CI_COMMIT_SHORT_SHA} -f ${PATH_PREFIX}${SERVICE_NAME}/Dockerfile.dev .
        - docker tag ${NAME}:${CI_COMMIT_SHORT_SHA} ${NAME}:${BRANCH}
        - echo "BRANCH_TAG=$BRANCH" >> build.env
    artifacts:
        reports:
            dotenv: build.env
    rules:
        - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
        - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'