Skip to content

Commit cf8d303

Browse files
nrichersvalidbeck
andauthored
Deploy PR previews to branch folders (#284)
* Add PR preview deploy and delete to docs-demo site * Re-add missing Makefile updates * Remove --delete option from deploy-demo * Update site/Makefile Co-authored-by: Beck <164545837+validbeck@users.noreply.github.com> * Tweak help wording --------- Co-authored-by: Beck <164545837+validbeck@users.noreply.github.com>
1 parent 1dd8c46 commit cf8d303

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

site/Makefile

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,26 @@ SRC_DIR := _source/developer-framework
33
DEST_DIR_NB := notebooks
44
DEST_DIR_PYTHON := _site/validmind
55
DEST_DIR_TESTS := tests
6+
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
67

78
# Define .PHONY target for help section
8-
.PHONY: help clean clone notebooks python-docs docs-site deploy-demo deploy-prod release-notes
9+
.PHONY: help clean clone notebooks python-docs docs-site deploy-demo deploy-demo-branch delete-demo-branch deploy-prod release-notes
910

1011
# Help section
1112
help:
1213
@echo "Available targets:"
13-
@echo " clean Remove the _source/ directory"
14-
@echo " clone Clone the developer-framework repository into _source/"
15-
@echo " notebooks Copy Jupyter notebooks into notebooks/"
16-
@echo " python-docs Copy the Python library docs into _site/validmind"
17-
@echo " get-source Get all source files (clean, clone, notebooks, python-docs)"
18-
@echo " docs-site Get all source files and render the docs site with Quarto"
19-
@echo " deploy-demo Render the docs site & deploy to docs-ci-cd-demo and clear cache"
20-
@echo " deploy-prod Render the docs site & deploy to docs-ci-cd-prod and clear cache"
21-
@echo " help Display this help message (default target)"
22-
@echo " release-notes Generate release notes from pull requests since latest tag and update _quarto.yml"
14+
@echo " clean Remove the _source/ directory"
15+
@echo " clone Clone the developer-framework repository into _source/"
16+
@echo " notebooks Copy Jupyter notebooks into notebooks/"
17+
@echo " python-docs Copy the Python library docs into _site/validmind"
18+
@echo " get-source Get all source files (clean, clone, notebooks, python-docs)"
19+
@echo " docs-site Get all source files and render the docs site with Quarto"
20+
@echo " deploy-demo Deploy docs demo site to s3://docs-ci-cd-demo/site/"
21+
@echo " deploy-demo-branch Deploy docs demo site to s3://docs-ci-cd-demo/site/pr_previews/$(GIT_BRANCH)/"
22+
@echo " delete-demo-branch Delete docs demo site in s3://docs-ci-cd-demo/site/pr_previews/$(GIT_BRANCH)/"
23+
@echo " deploy-prod Deploy docs prod site to s3://docs-ci-cd-prod/site/"
24+
@echo " help Display this help message (default target)"
25+
@echo " release-notes Generate release notes from pull requests since latest tag and update _quarto.yml"
2326

2427
# Clean up source directory
2528
clean:
@@ -82,9 +85,19 @@ deploy-demo:
8285
echo "You're not on the docs-demo branch, no action taken."; \
8386
else \
8487
echo "\nDeploying docs-demo site ..."; \
85-
quarto render && aws s3 sync ./_site s3://docs-ci-cd-demo/site/ --delete && aws cloudfront create-invalidation --distribution-id E38AINJY5CYN6P --paths "/*" --no-cli-pager > /dev/null; \
88+
quarto render && aws s3 sync ./_site s3://docs-ci-cd-demo/site/ && aws cloudfront create-invalidation --distribution-id E38AINJY5CYN6P --paths "/*" --no-cli-pager > /dev/null; \
8689
fi
8790

91+
# Deploy PR branch to https://docs-demo.vm.validmind.ai/
92+
deploy-demo-branch:
93+
@quarto render && aws s3 sync ./_site s3://docs-ci-cd-demo/site/pr_previews/$(GIT_BRANCH)/ --delete && aws cloudfront create-invalidation --distribution-id E38AINJY5CYN6P --paths "/*" --no-cli-pager > /dev/null;
94+
@echo "\nDeployed to https://docs-demo.vm.validmind.ai/pr_previews/$(GIT_BRANCH)/index.html"
95+
96+
# Delete PR branch on https://docs-demo.vm.validmind.ai/
97+
delete-demo-branch:
98+
@aws s3 rm s3://docs-ci-cd-demo/site/pr_previews/$(GIT_BRANCH)/ --recursive && aws cloudfront create-invalidation --distribution-id E38AINJY5CYN6P --paths "/*" --no-cli-pager > /dev/null;
99+
@echo "\nDeleted https://docs-demo.vm.validmind.ai/pr_previews/$(GIT_BRANCH)/"
100+
88101
# Deployment to https://docs.validmind.ai/
89102
deploy-prod:
90103
@if [ "`git rev-parse --abbrev-ref HEAD`" != "prod" ]; then \

0 commit comments

Comments
 (0)