opentofu/website/scripts/website-build.sh
Kevin Wang 2563bf3f96
feat: support local preview, post split; add deploy preview (#30814)
* chore: support local preview, post split

* feat: deploy preview

* update script perms
- chmod +x ./website/scripts/website-build.sh

* npm i

* chore: website-build uses 'kevin/terraform-split'

* deploy preview test

* chore: test

* PREVIEW_DIR & CLONE_DIR = preview

* rm dupe preview path

* empty commit

* ../data & ..docs

* website-preview

* remove REPO var

* move `intro` and `guides` back to where they were

* empty commit

* chore move `intro` and `guides`

* chore: copy over images

* move images into `/website`
- content API requires this

* chore: `CURRENT_GIT_BRANCH`

* fix: `CURRENT_GIT_BRANCH`

* fix `CURRENT_GIT_BRANCH`

* debug current dir

* fix `CURRENT_GIT_BRANCH`

* chore: comment CURRENT_GIT_BRANCH

* Update Makefile

* Update website/scripts/website-build.sh

* optimize images

* chore(Makefile): move vars to top

* remove branch
2022-04-21 13:58:16 -04:00

39 lines
1.3 KiB
Bash
Executable File

# Repo which we are cloning and executing npm run build:deploy-preview within
REPO_TO_CLONE=terraform-website
# Set the subdirectory name for the terraform-website app
PREVIEW_DIR=website-preview
CLONE_DIR=website-preview
# Get the git branch of the commit that triggered the deploy preview
# - https://vercel.com/docs/concepts/projects/environment-variables#system-environment-variables
# This will power remote image assets in local and deploy previews
CURRENT_GIT_BRANCH=$VERCEL_GIT_COMMIT_REF
echo "CURRENT_GIT_BRANCH is $CURRENT_GIT_BRANCH"
from_cache=false
if [ -d "$PREVIEW_DIR" ]; then
echo "$PREVIEW_DIR found"
CLONE_DIR="$PREVIEW_DIR-tmp"
from_cache=true
fi
# Clone the terraform-website project, if needed
echo "⏳ Cloning the terraform-website repo, this might take a while..."
git clone --depth=1 https://github.com/hashicorp/$REPO_TO_CLONE.git "$CLONE_DIR"
if [ "$from_cache" = true ]; then
echo "Setting up $PREVIEW_DIR"
cp -R "./$CLONE_DIR/." "./$PREVIEW_DIR"
fi
# cd into the preview directory project
cd "$PREVIEW_DIR"
# Run the terraform-website content-repo start script
PREVIEW_FROM_REPO=terraform \
NAV_DATA_DIRNAME=../data \
CONTENT_DIRNAME=../docs \
IS_CONTENT_PREVIEW=true \
CURRENT_GIT_BRANCH=$CURRENT_GIT_BRANCH \
npm run build:deploy-preview