Skip to content
This repository was archived by the owner on Jun 29, 2018. It is now read-only.

Commit 1923b40

Browse files
committed
Auto-deploy for docs to gh-pages
1 parent 00ef6b3 commit 1923b40

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<build-plugin.coveralls.version>4.0.0</build-plugin.coveralls.version>
2424
<build-plugin.gpg.version>1.6</build-plugin.gpg.version>
2525
<build-plugin.asciidoctor.version>1.5.2</build-plugin.asciidoctor.version>
26+
<build-plugin.exec.version>1.4.0</build-plugin.exec.version>
2627
</properties>
2728
<modules>
2829
<module>spring-boot-admin-server</module>
@@ -101,6 +102,11 @@
101102
<artifactId>asciidoctor-maven-plugin</artifactId>
102103
<version>${build-plugin.asciidoctor.version}</version>
103104
</plugin>
105+
<plugin>
106+
<groupId>org.codehaus.mojo</groupId>
107+
<artifactId>exec-maven-plugin</artifactId>
108+
<version>${build-plugin.exec.version}</version>
109+
</plugin>
104110
</plugins>
105111
</pluginManagement>
106112
</build>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
##
3+
# Makes a shallow clone for gh-pages branch, copies the new docs, adds, commits and pushes 'em.
4+
#
5+
# Requires the environment variable GH_TOKEN to be set to a valid GitHub-api-token.
6+
#
7+
# Usage:
8+
# ./deploy-gh-pages.sh <project-version>
9+
#
10+
# project-version The version folder to use in gh-pages
11+
##
12+
set -o errexit -o nounset
13+
14+
PROJECT_VERSION=$1
15+
16+
GH_URL="https://${GH_TOKEN}@github.com/codecentric/spring-boot-admin.git"
17+
TEMPDIR="$(mktemp -d /tmp/gh-pages.XXX)"
18+
19+
echo "Cloning gh-pages branch..."
20+
git clone --branch gh-pages --single-branch --depth 1 --config user.name="Johannes Edmeier" --config user.email="[email protected]" "$GH_URL" "$TEMPDIR"
21+
22+
if [[ -d "$TEMPDIR"/"${PROJECT_VERSION}-SNAPSHOT" ]]; then
23+
echo "Removing ${PROJECT_VERSION}-SNAPSHOT..."
24+
rm -rf "$TEMPDIR"/"${PROJECT_VERSION}-SNAPSHOT"
25+
fi
26+
27+
echo "Copying new docs..."
28+
mkdir -p "$TEMPDIR"/"${PROJECT_VERSION}"
29+
cp -r target/generated-docs/* "$TEMPDIR"/"${PROJECT_VERSION}"/
30+
31+
pushd "$TEMPDIR" >/dev/null
32+
git add .
33+
34+
if git diff-index --quiet HEAD; then
35+
echo "No changes detected."
36+
else
37+
echo "Commit changes..."
38+
git commit --message "Docs for ${PROJECT_VERSION}"
39+
echo "Pushing gh-pages..."
40+
git push origin gh-pages
41+
fi
42+
43+
popd >/dev/null
44+
45+
rm -rf "$TEMPDIR"
46+
exit 0

spring-boot-admin-docs/pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,25 @@
3737
</execution>
3838
</executions>
3939
</plugin>
40+
<plugin>
41+
<groupId>org.codehaus.mojo</groupId>
42+
<artifactId>exec-maven-plugin</artifactId>
43+
<executions>
44+
<execution>
45+
<id>deploy-gh-pages</id>
46+
<phase>deploy</phase>
47+
<goals>
48+
<goal>exec</goal>
49+
</goals>
50+
<configuration>
51+
<executable>./deploy-gh-pages.sh</executable>
52+
<arguments>
53+
<argument>${project.version}</argument>
54+
</arguments>
55+
</configuration>
56+
</execution>
57+
</executions>
58+
</plugin>
4059
</plugins>
4160
</build>
4261
</project>

0 commit comments

Comments
 (0)