Skip to content

Commit

Permalink
Merge pull request #40 from CircleCI-Public/usage
Browse files Browse the repository at this point in the history
Generate docs for the CLI
  • Loading branch information
Zachary Scott authored Aug 6, 2018
2 parents 8ba342f + 0cfb929 commit ed68ed1
Show file tree
Hide file tree
Showing 42 changed files with 7,468 additions and 2,760 deletions.
17 changes: 15 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ jobs:
destination: coverage.txt
- codecov/upload:
path: coverage.txt
docs:
executor: go
steps:
- checkout
- run: sudo apt-get install pandoc
- run: go run main.go usage
- store_artifacts:
path: ./docs
destination: docs
- run: ./.circleci/deploy-gh-pages.sh

lint:
docker:
Expand Down Expand Up @@ -55,8 +65,8 @@ jobs:
- run:
name: Tag Repo
command: |
git config --global user.email "[email protected]"
git config --global user.name "Marc O'Morain"
git config --global user.email $GH_EMAIL
git config --global user.name $GH_NAME
git tag -a "v0.1.$CIRCLE_BUILD_NUM" -m "Release v0.1.$CIRCLE_BUILD_NUM"
git push origin "v0.1.$CIRCLE_BUILD_NUM"
- run:
Expand Down Expand Up @@ -93,6 +103,9 @@ workflows:
- test
- coverage
- lint
- docs:
requires:
- deploy
- deploy:
requires:
- test
Expand Down
48 changes: 48 additions & 0 deletions .circleci/deploy-gh-pages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/sh
# ideas used from https://gist.github.com/motemen/8595451

# Based on https://github.com/eldarlabs/ghpages-deploy-script/blob/master/scripts/deploy-ghpages.sh
# Used with their MIT license https://github.com/eldarlabs/ghpages-deploy-script/blob/master/LICENSE

# abort the script if there is a non-zero error
set -e

# show where we are on the machine
pwd
remote=$(git config remote.origin.url)

# make a directory to put the gp-pages branch
mkdir gh-pages-branch
cd gh-pages-branch
# now lets setup a new repo so we can update the gh-pages branch
git config --global user.email "$GH_EMAIL" > /dev/null 2>&1
git config --global user.name "$GH_NAME" > /dev/null 2>&1
git init
git remote add --fetch origin "$remote"

# switch into the the gh-pages branch
if git rev-parse --verify origin/gh-pages > /dev/null 2>&1
then
git checkout gh-pages
# delete any old site as we are going to replace it
# Note: this explodes if there aren't any, so moving it here for now
git rm -rf .
else
git checkout --orphan gh-pages
fi

# copy over or recompile the new site
cp -a "../out/." .

# stage any changes and new files
git add -A
# now commit, ignoring branch gh-pages doesn't seem to work, so trying skip
git commit --allow-empty -m "Deploy to GitHub pages [ci skip]"
# and push, but send any output to /dev/null to hide anything sensitive
git push --force --quiet origin gh-pages
# go back to where we started and remove the gh-pages git repo we made and used
# for deployment
cd ..
rm -rf gh-pages-branch

echo "Finished Deployment!"
18 changes: 18 additions & 0 deletions .circleci/generate-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

set -e

# generate markdown docs
go run main.go usage

# setup output dir
mkdir -p out

# pandoc markdown to html into out dir
for f in docs/*.md; do
pandoc "$f" -s -o "out/$(basename ${f%.md}.html)";
done

# move index and update links
mv out/circleci.html out/index.html
sed -i -- 's#<a href="circleci.html">#<a href="index.html">#g' out/*.html
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ TODO
circleci-cli
coverage.txt
dist/
docs/
out/
.vscode
Loading

0 comments on commit ed68ed1

Please sign in to comment.