Skip to content

Commit 8962086

Browse files
author
Sam Kleinman
committed
build: avoiding publication builds if the site is current
1 parent a1850b7 commit 8962086

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

bin/published-build-check

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
CURRENT_BRANCH=$1
4+
CURRENT_COMMIT=$2
5+
6+
published-commit(){
7+
curl -s http://docs.mongodb.org/$CURRENT_BRANCH/release.txt
8+
}
9+
10+
CURRENT_PUBLISHED_BRANCH=`published-commit`
11+
12+
if [ $CURRENT_COMMIT = $CURRENT_PUBLISHED_BRANCH ]; then
13+
echo "[build]: Error. The published version of '$CURRENT_BRANCH' matches the last commit of this repo."
14+
echo " Commit local changes before publishing."
15+
exit 1
16+
else
17+
echo [buid]: Last commit on \'$CURRENT_BRANCH\' is different from the published version. Update, if needed, and deploy at will.
18+
fi

makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ public-branch-output = $(public-output)/$(current-branch)
1111

1212
# change this to reflect the branch that "manual/" will point to
1313
manual-branch = master
14-
# intuit the current branch
14+
# intuit the current branch and commit
1515
current-branch := $(shell git symbolic-ref HEAD 2>/dev/null | cut -d "/" -f "3" )
16+
last-commit := $(shell git rev-parse --verify HEAD)
1617

1718
ifeq ($(current-branch),$(manual-branch))
1819
current-if-not-manual = $(manual-branch)
@@ -64,15 +65,22 @@ help:
6465
# Meta targets that control the build and publication process.
6566
#
6667

67-
push:publish
68+
.PHONY: push publish-if-up-to-date
69+
70+
push:publish-if-up-to-date
6871
@echo [build]: copying the new $(current-branch) build to the web servers.
6972
$(MAKE) MODE='push' push-dc1 push-dc2
7073
@echo [build]: deployed a new build of the $(current-branch) branch of the Manual.
74+
7175
push-all:publish
7276
@echo [build]: copying the full docs site to the web servers.
7377
$(MAKE) MODE='push' push-all-dc1 push-all-dc2
7478
@echo [build]: deployed a new build of the full Manual.
7579

80+
publish-if-up-to-date:
81+
@bin/published-build-check $(current-branch) $(last-commit)
82+
$(MAKE) publish
83+
7684
publish:initial-dependencies
7785
$(MAKE) sphinx-components static-components
7886
@echo [build]: $(manual-branch) branch is succeessfully deployed to '$(public-output)'.

0 commit comments

Comments
 (0)