github.com/terramate-io/tf@v0.0.0-20230830114523-fce866b4dfcd/website/scripts/website-start.sh (about)

     1  # Copyright (c) HashiCorp, Inc.
     2  # SPDX-License-Identifier: MPL-2.0
     3  
     4  ######################################################
     5  # NOTE: This file is managed by the Digital Team's   #
     6  # Terraform configuration @ hashicorp/mktg-terraform #
     7  ######################################################
     8  
     9  # Repo which we are cloning and executing npm run build:deploy-preview within
    10  REPO_TO_CLONE=dev-portal
    11  # Set the subdirectory name for the dev-portal app
    12  PREVIEW_DIR=website-preview
    13  # The product for which we are building the deploy preview
    14  PRODUCT=terraform
    15  # Preview mode, controls the UI rendered (either the product site or developer). Can be `io` or `developer`
    16  PREVIEW_MODE=developer
    17  
    18  # Get the git branch of the commit that triggered the deploy preview
    19  # This will power remote image assets in local and deploy previews
    20  CURRENT_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
    21  
    22  # This is where content files live, relative to the website-preview dir. If omitted, "../content" will be used
    23  LOCAL_CONTENT_DIR=../docs
    24  
    25  should_pull=true
    26  
    27  # Clone the dev-portal project, if needed
    28  if [ ! -d "$PREVIEW_DIR" ]; then
    29      echo "⏳ Cloning the $REPO_TO_CLONE repo, this might take a while..."
    30      git clone --depth=1 https://github.com/hashicorp/$REPO_TO_CLONE.git "$PREVIEW_DIR"
    31      should_pull=false
    32  fi
    33  
    34  cd "$PREVIEW_DIR"
    35  
    36  # If the directory already existed, pull to ensure the clone is fresh
    37  if [ "$should_pull" = true ]; then
    38      git pull origin main
    39  fi
    40  
    41  # Run the dev-portal content-repo start script
    42  REPO=$PRODUCT \
    43  PREVIEW_FROM_REPO=$PRODUCT \
    44  LOCAL_CONTENT_DIR=$LOCAL_CONTENT_DIR \
    45  CURRENT_GIT_BRANCH=$CURRENT_GIT_BRANCH \
    46  PREVIEW_MODE=$PREVIEW_MODE \
    47  npm run start:local-preview