-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Update Digital Team Files (#1083)
Co-authored-by: Kevin Wang <kwangsan@gmail.com>
- Loading branch information
1 parent
8058e80
commit b5b7dd0
Showing
5 changed files
with
155 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
###################################################### | ||
# NOTE: This file is managed by the Digital Team's # | ||
# Terraform configuration @ hashicorp/mktg-terraform # | ||
###################################################### | ||
|
||
.DEFAULT_GOAL := website | ||
|
||
# Set the preview mode for the website shell to "developer" or "io" | ||
PREVIEW_MODE ?= developer | ||
REPO ?= terraform-plugin-sdk | ||
|
||
# Enable setting alternate docker tool, e.g. 'make DOCKER_CMD=podman' | ||
DOCKER_CMD ?= docker | ||
|
||
CURRENT_GIT_BRANCH=$$(git rev-parse --abbrev-ref HEAD) | ||
LOCAL_CONTENT_DIR=../docs | ||
PWD=$$(pwd) | ||
|
||
DOCKER_IMAGE="hashicorp/dev-portal" | ||
DOCKER_IMAGE_LOCAL="dev-portal-local" | ||
DOCKER_RUN_FLAGS=-it \ | ||
--publish "3000:3000" \ | ||
--rm \ | ||
--tty \ | ||
--volume "$(PWD)/docs:/app/docs" \ | ||
--volume "$(PWD)/img:/app/public" \ | ||
--volume "$(PWD)/data:/app/data" \ | ||
--volume "$(PWD)/redirects.js:/app/redirects.js" \ | ||
--volume "next-dir:/app/website-preview/.next" \ | ||
--volume "$(PWD)/.env:/app/.env" \ | ||
-e "REPO=$(REPO)" \ | ||
-e "PREVIEW_FROM_REPO=$(REPO)" \ | ||
-e "IS_CONTENT_PREVIEW=true" \ | ||
-e "LOCAL_CONTENT_DIR=$(LOCAL_CONTENT_DIR)" \ | ||
-e "CURRENT_GIT_BRANCH=$(CURRENT_GIT_BRANCH)" \ | ||
-e "PREVIEW_MODE=$(PREVIEW_MODE)" | ||
|
||
# Default: run this if working on the website locally to run in watch mode. | ||
.PHONY: website | ||
website: | ||
@echo "==> Downloading latest Docker image..." | ||
@$(DOCKER_CMD) pull $(DOCKER_IMAGE) | ||
@echo "==> Starting website..." | ||
@$(DOCKER_CMD) run $(DOCKER_RUN_FLAGS) $(DOCKER_IMAGE) | ||
|
||
# Use this if you have run `website/build-local` to use the locally built image. | ||
.PHONY: website/local | ||
website/local: | ||
@echo "==> Starting website from local image..." | ||
@$(DOCKER_CMD) run $(DOCKER_RUN_FLAGS) $(DOCKER_IMAGE_LOCAL) | ||
|
||
# Run this to generate a new local Docker image. | ||
.PHONY: website/build-local | ||
website/build-local: | ||
@echo "==> Building local Docker image" | ||
@$(DOCKER_CMD) build https://github.com/hashicorp/dev-portal.git\#main \ | ||
-t $(DOCKER_IMAGE_LOCAL) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
###################################################### | ||
# NOTE: This file is managed by the Digital Team's # | ||
# Terraform configuration @ hashicorp/mktg-terraform # | ||
###################################################### | ||
|
||
# This is run during the website build step to determine if we should skip the build or not. | ||
# More information: https://vercel.com/docs/platform/projects#ignored-build-step | ||
|
||
if [[ "$VERCEL_GIT_COMMIT_REF" == "stable-website" ]] ; then | ||
# Proceed with the build if the branch is stable-website | ||
echo "✅ - Build can proceed" | ||
exit 1; | ||
else | ||
# Check for differences in the website directory | ||
git diff --quiet HEAD^ HEAD ./ | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,52 @@ | ||
############################################################# | ||
# Note: This script is maintained by the Web / Digital team # | ||
# # | ||
# This is meant to be executed during a Vercel CI job, and # | ||
# not locally. # | ||
############################################################# | ||
###################################################### | ||
# NOTE: This file is managed by the Digital Team's # | ||
# Terraform configuration @ hashicorp/mktg-terraform # | ||
###################################################### | ||
|
||
# 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 | ||
REPO_TO_CLONE=dev-portal | ||
# Set the subdirectory name for the base project | ||
PREVIEW_DIR=website-preview | ||
# The directory we want to clone the project into | ||
CLONE_DIR=website-preview | ||
# The product for which we are building the deploy preview | ||
PRODUCT=terraform-plugin-sdk | ||
# Preview mode, controls the UI rendered (either the product site or developer). Can be `io` or `developer` | ||
PREVIEW_MODE=developer | ||
|
||
# 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" | ||
# This is where content files live, relative to the website-preview dir. If omitted, "../content" will be used | ||
LOCAL_CONTENT_DIR=../docs | ||
|
||
from_cache=false | ||
|
||
if [ -d "$PREVIEW_DIR" ]; then | ||
echo "$PREVIEW_DIR found" | ||
CLONE_DIR="$PREVIEW_DIR-tmp" | ||
from_cache=true | ||
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" | ||
# Clone the base project, if needed | ||
echo "⏳ Cloning the $REPO_TO_CLONE 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" | ||
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-docs-common \ | ||
NAV_DATA_DIRNAME=../data \ | ||
CONTENT_DIRNAME=../docs \ | ||
# Run the build:deploy-preview start script | ||
PREVIEW_FROM_REPO=$PRODUCT \ | ||
IS_CONTENT_PREVIEW=true \ | ||
PREVIEW_MODE=$PREVIEW_MODE \ | ||
REPO=$PRODUCT \ | ||
HASHI_ENV=project-preview \ | ||
LOCAL_CONTENT_DIR=$LOCAL_CONTENT_DIR \ | ||
CURRENT_GIT_BRANCH=$CURRENT_GIT_BRANCH \ | ||
npm run build:deploy-preview |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
###################################################### | ||
# NOTE: This file is managed by the Digital Team's # | ||
# Terraform configuration @ hashicorp/mktg-terraform # | ||
###################################################### | ||
|
||
# Repo which we are cloning and executing npm run build:deploy-preview within | ||
REPO_TO_CLONE=dev-portal | ||
# Set the subdirectory name for the dev-portal app | ||
PREVIEW_DIR=website-preview | ||
# The product for which we are building the deploy preview | ||
PRODUCT=terraform-plugin-sdk | ||
# Preview mode, controls the UI rendered (either the product site or developer). Can be `io` or `developer` | ||
PREVIEW_MODE=developer | ||
|
||
# Get the git branch of the commit that triggered the deploy preview | ||
# This will power remote image assets in local and deploy previews | ||
CURRENT_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD) | ||
|
||
# This is where content files live, relative to the website-preview dir. If omitted, "../content" will be used | ||
LOCAL_CONTENT_DIR=../docs | ||
|
||
should_pull=true | ||
|
||
# Clone the dev-portal project, if needed | ||
if [ ! -d "$PREVIEW_DIR" ]; then | ||
echo "⏳ Cloning the $REPO_TO_CLONE repo, this might take a while..." | ||
git clone --depth=1 https://github.com/hashicorp/$REPO_TO_CLONE.git "$PREVIEW_DIR" | ||
should_pull=false | ||
fi | ||
|
||
cd "$PREVIEW_DIR" | ||
|
||
# If the directory already existed, pull to ensure the clone is fresh | ||
if [ "$should_pull" = true ]; then | ||
git pull origin main | ||
fi | ||
|
||
# Run the dev-portal content-repo start script | ||
REPO=$PRODUCT \ | ||
PREVIEW_FROM_REPO=$PRODUCT \ | ||
LOCAL_CONTENT_DIR=$LOCAL_CONTENT_DIR \ | ||
CURRENT_GIT_BRANCH=$CURRENT_GIT_BRANCH \ | ||
PREVIEW_MODE=$PREVIEW_MODE \ | ||
npm run start:local-preview |