Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate docs for the CLI #40

Merged
merged 6 commits into from
Aug 6, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 All @@ -81,6 +91,9 @@ workflows:
- test
- coverage
- lint
- docs:
requires:
- deploy
- deploy:
requires:
- test
Expand Down
52 changes: 52 additions & 0 deletions .circleci/deploy-gh-pages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/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 "../docs/." .

# move index and update links
mv circleci.html index.html
sed -i -- 's#<a href="circleci.html">#<a href="index.html">#g' *.html
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do this moving and replacement from somewhere else, so that you his script is just concerned with pushing to gh-pages.

Having these two lines in the middle of this script is surprising to the reader.


# 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!"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ TODO
circleci-cli
coverage.txt
dist/
docs/
.vscode
Loading