From cf6df7190c9b2494291e8104874667eea1b3c079 Mon Sep 17 00:00:00 2001 From: Charlie Drage Date: Thu, 23 Mar 2017 10:58:19 -0400 Subject: [PATCH] Sync changes from master to gh-pages on each merge request This adds the functionality for Travis to sync with http://kompose.io in regards to "syncing" the docs directory in master and the docs within gh-pages. Two things are added: script/sync-docs/sh script/deploy_key.enc The encrypted key follows the conventions here: https://gist.github.com/domenic/ec8b0fc8ab45f39403dd and the functionality of running: `travis encrypt-file encrypt_key` The script is ran each-time a PR is merged (and only if it's sucessful!) as per the modifications in `.travis.yml`. Thus each time we make a change in master, there's no need to open up another PR for syncing the changes with `gh-pages`. --- .travis.yml | 13 +++++--- script/deploy_key.enc | Bin 0 -> 3248 bytes script/sync-docs.sh | 67 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 script/deploy_key.enc create mode 100755 script/sync-docs.sh diff --git a/.travis.yml b/.travis.yml index 90d4ceef..a84f3594 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,10 +7,13 @@ language: go # make this also work for forks go_import_path: github.com/kubernetes-incubator/kompose -go: - - 1.6 - - 1.7 - - 1.8 +matrix: + include: + - go: 1.6 + # Only build docs once + env: BUILD_DOCS=yes + - go: 1.7 + - go: 1.8 before_install: - go get github.com/mattn/goveralls @@ -29,3 +32,5 @@ after_success: # gover collects all .coverprofile files and saves it to one file gover.coverprofile - gover - goveralls -coverprofile=gover.coverprofile -service=travis-ci + # sync the docs only if everything else was successful + - ./script/sync-docs.sh diff --git a/script/deploy_key.enc b/script/deploy_key.enc new file mode 100644 index 0000000000000000000000000000000000000000..ec49a43c43f4955a636e807ff483b7d697ae9421 GIT binary patch literal 3248 zcmV;h3{UeUM6rZe9VeMOf%$WGTSpys(Yl20QTUYKOQA^~JO zXKRV3k-LY82}K=3$F&OCN-APh)gvb?D12iCg<*o9Q}B8*E(0?^##_jCBCZuSOXIaaG=NL4icL~2Olcn!31gdtMT7#F~AmydQM zp%_Sm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ut29l>^B zx~P81M@4so9|m&f*^d2m=<{RM);Ik~>wCPl&aVK&@c6=eFYn;W#CjZ{GMJWU^QN4$ zYTn}*dyG)^D+Fx0tW(;5tJKyv=Unp9L|5~vAxtW6PXPAd4nRD`m}wC)BW&I{JI_!a zph2{Ydv$NUQJ&Hnsx*(f&(U~QI|%UcZ8~WA@+N*12dm#;U`#}UCz5~_G+ju2Kyj=P z9~f9L zx2R*ad3xQbE!fsj^kI|p7xcM!Ujkqjo=Rn(m{P0^oWNY}0}Yj(U&c8sF`D#MTrizN z-#Nl=`Erf+mP-p~yr!_0U~4mgjS{?*DrVrrD73TVw2b%L!>u^G5wp^MF3+I*-kq(C z(I3vhdCb=;)n6~EuSsB&f;cDqIH=5y8rBOH!N$}+a<&C=?4pkg&7FRqga9mNM zYfraBT*Q6d!|{upJ&p9}R^>DHOQuNfaPuA9B9aN#)fYQmw!E#?sXQ2&6gD1ATMECn2>R*HaN5WiIKkU zUMN&qAAD(V^`hcwsDtIl$aA|Uj}8RoA*Aj~Wa%%aA%om{A3DHQI;n=IoX1Azt(aQ`(RsZ5@pK3V*)_xDLjL&I_pY6S`*JQ6iwP;@E;0a}@D7GcH02 ih?Pu|dv0%5xsJeDSE>48HmoP>M0RXfINCo|aq literal 0 HcmV?d00001 diff --git a/script/sync-docs.sh b/script/sync-docs.sh new file mode 100755 index 00000000..1401ecee --- /dev/null +++ b/script/sync-docs.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash + +# Ensures that we run on Travis +if [ "$TRAVIS_BRANCH" != "master" ] || [ "$BUILD_DOCS" != "yes" ] || [ "$TRAVIS_SECURE_ENV_VARS" == "false" ] || [ "$TRAVIS_PULL_REQUEST" != "false" ] ; then + echo "Must be: a merged pr on the master branch, BUILD_DOCS=yes, TRAVIS_SECURE_ENV_VARS=false" + exit 0 +fi + +DOCS_REPO_NAME="kompose" +DOCS_REPO_URL="git@github.com:kubernetes-incubator/kompose.git" +DOCS_KEY="script/deploy_key" +DOCS_USER="komposebot" +DOCS_EMAIL="cdrage+kompose@redhat.com" +DOCS_BRANCH="gh-pages" +DOCS_FOLDER="docs" + +# decrypt the private key +openssl aes-256-cbc -K $encrypted_b1c51b116939_key -iv $encrypted_b1c51b116939_iv -in "$DOCS_KEY.enc" -out "$DOCS_KEY" -d +chmod 600 "$DOCS_KEY" +eval `ssh-agent -s` +ssh-add "$DOCS_KEY" + +# clone the repo +git clone "$DOCS_REPO_URL" "$DOCS_REPO_NAME" + +# change to that directory (to prevent accidental pushing to master, etc.) +cd "$DOCS_REPO_NAME" + +# switch to gh-pages and grab the docs folder from master +git checkout gh-pages +git checkout master docs + +# clean-up the docs and convert to jekyll-friendly docs +cd docs +for filename in *.md; do + if cat $filename | head -n 1 | grep "\-\-\-"; + then + echo "$filename already contains Jekyll format" + else + echo "Adding Jekyll file format to $filename" + jekyll="--- +layout: default +permalink: /$filename/ +--- +" + echo -e "$jekyll\n$(cat $filename)" > $filename + fi +done +cd .. + +# remove README.md from docs folder as it isn't relevant +rm docs/README.md + +# add relevant user information +git config user.name "$DOCS_USER" + +# email assigned to @komposebot +git config user.email "$DOCS_EMAIL" +git add --all + +# Check if anything changed, and if it's the case, push to origin/master. +if git commit -m 'Update docs' -m "Commit: https://github.com/kubernetes-incubator/kompose/commit/$TRAVIS_COMMIT" ; then + git push +fi + +# cd back to the original root folder +cd ..