Browse code

Update docs release script so we can have autodeploys to docs.master.dockerproject.com.

- Make the invaidation profile the bucket variable, not hard coded.
- Add no cache variable for settings cache to "no-cache"

Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)

Jessica Frazelle authored on 2015/01/10 05:10:54
Showing 3 changed files
... ...
@@ -28,3 +28,4 @@ docs/AWS_S3_BUCKET
28 28
 docs/GIT_BRANCH
29 29
 docs/VERSION
30 30
 docs/GITCOMMIT
31
+docs/changed-files
... ...
@@ -30,7 +30,7 @@ DOCKER_DOCS_IMAGE := docker-docs$(if $(GIT_BRANCH),:$(GIT_BRANCH))
30 30
 
31 31
 DOCKER_RUN_DOCKER := docker run --rm -it --privileged $(DOCKER_ENVS) $(DOCKER_MOUNT) "$(DOCKER_IMAGE)"
32 32
 
33
-DOCKER_RUN_DOCS := docker run --rm -it $(DOCS_MOUNT) -e AWS_S3_BUCKET
33
+DOCKER_RUN_DOCS := docker run --rm -it $(DOCS_MOUNT) -e AWS_S3_BUCKET -e NOCACHE
34 34
 
35 35
 # for some docs workarounds (see below in "docs-build" target)
36 36
 GITCOMMIT := $(shell git rev-parse --short HEAD 2>/dev/null)
... ...
@@ -83,7 +83,7 @@ build: bundles
83 83
 	docker build -t "$(DOCKER_IMAGE)" .
84 84
 
85 85
 docs-build:
86
-	git diff --name-status upstream/release..upstream/docs docs/ > docs/changed-files
86
+	( git remote | grep -v upstream ) || git diff --name-status upstream/release..upstream/docs docs/ > docs/changed-files
87 87
 	cp ./VERSION docs/VERSION
88 88
 	echo "$(GIT_BRANCH)" > docs/GIT_BRANCH
89 89
 	echo "$(AWS_S3_BUCKET)" > docs/AWS_S3_BUCKET
... ...
@@ -78,6 +78,11 @@ upload_current_documentation() {
78 78
 	src=site/
79 79
 	dst=s3://$BUCKET$1
80 80
 
81
+	cache=max-age=3600
82
+	if [ "$NOCACHE" ]; then
83
+		cache=no-cache
84
+	fi
85
+
81 86
 	echo
82 87
 	echo "Uploading $src"
83 88
 	echo "  to $dst"
... ...
@@ -90,7 +95,7 @@ upload_current_documentation() {
90 90
 	#  versions.html_fragment
91 91
 		include="--recursive --include \"*.$i\" "
92 92
 		echo "uploading *.$i"
93
-		run="aws s3 cp $src $dst $OPTIONS --profile $BUCKET --cache-control \"max-age=3600\" --acl public-read $include"
93
+		run="aws s3 cp $src $dst $OPTIONS --profile $BUCKET --cache-control $cache --acl public-read $include"
94 94
 		echo "======================="
95 95
 		echo "$run"
96 96
 		echo "======================="
... ...
@@ -114,7 +119,7 @@ invalidate_cache() {
114 114
 
115 115
 	len=${#files[@]}
116 116
 
117
-	echo "aws cloudfront  create-invalidation --profile docs.docker.com --distribution-id $DISTRIBUTION_ID --invalidation-batch '" > batchfile
117
+	echo "aws cloudfront  create-invalidation --profile $AWS_S3_BUCKET --distribution-id $DISTRIBUTION_ID --invalidation-batch '" > batchfile
118 118
 	echo "{\"Paths\":{\"Quantity\":$len," >> batchfile
119 119
 	echo "\"Items\": [" >> batchfile
120 120
 
... ...
@@ -150,7 +155,7 @@ if [ "$BUILD_ROOT" == "yes" ]; then
150 150
 	echo "Building root documentation"
151 151
 	build_current_documentation
152 152
 	upload_current_documentation
153
-	invalidate_cache
153
+	[ "$NOCACHE" ] || invalidate_cache
154 154
 fi
155 155
 
156 156
 #build again with /v1.0/ prefix
... ...
@@ -158,4 +163,4 @@ sed -i "s/^site_url:.*/site_url: \/$MAJOR_MINOR\//" mkdocs.yml
158 158
 echo "Building the /$MAJOR_MINOR/ documentation"
159 159
 build_current_documentation
160 160
 upload_current_documentation "/$MAJOR_MINOR/"
161
-invalidate_cache "/$MAJOR_MINOR"
161
+[ "$NOCACHE" ] || invalidate_cache "/$MAJOR_MINOR"