Skip to content

Commit

Permalink
Merge pull request #13 from nielsenramon/nr-circle
Browse files Browse the repository at this point in the history
Add circle configs
  • Loading branch information
Nielsen Ramon committed Nov 25, 2015
2 parents 43f18a8 + a3c7c48 commit 0f13e27
Show file tree
Hide file tree
Showing 20 changed files with 221 additions and 110 deletions.
10 changes: 0 additions & 10 deletions .travis.yml

This file was deleted.

41 changes: 13 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Setup your environment:

bin/setup

Don't forget to enable your repository on [Circle CI](https://circleci.com/docs/getting-started)!

*If you do not want the Kickster files but just the deploy then copy the `bin/deploy` script to your repo and your ready to go.*

## Development
Expand All @@ -30,10 +32,10 @@ Run Jekyll:
Used tools:
- [Autoprefixer](https://github.com/postcss/autoprefixer)
- [Bower](http://bower.io/)
- [Circle CI](https://circleci.com/)
- [Jekyll](http://jekyllrb.com/)
- [Jekyll assets](https://github.com/jekyll/jekyll-assets)
- [HTML5 Boilerplate](https://html5boilerplate.com/) (Influenced by)
- [Travis CI](http://travis-ci.org)

## Manual deploy to GitHub Pages

Expand All @@ -43,47 +45,30 @@ Run this in the root project folder in your console:

That's it, enjoy your nicely build project on GitHub pages!

## Automated deployment with TravisCI
## Automated deployment with Circle CI

Automated deployment is by default not included in your Kickster generated Jekyll project. Please follow the steps below to include automated deployment.

*Note that changes will only deploy when your code is merged into master.*

#### 1. Copy the required automated deploy script

Copy the [automated](https://github.com/nielsenramon/kickster/blob/master/snippets/automated) script inside the `/bin` folder of your project.

#### 2. Update `.travis.yml`

Replace your `.travis.yml` file with [this](https://github.com/nielsenramon/kickster/blob/master/snippets/.travis.yml) one.
And adjust the following 2 lines with your information:

- USERNAME: <your-github-username>
- EMAIL: <your-github-email>

#### 3. Create a personal access token

This is required to push to the GitHub repo from a script.

In GitHub go to `settings > Personal access tokens` and create a new one.
First give it a proper name so it is easy to recognize later. Then check `repo` (check `public_repo` if it is a public repository) and click on create.

<img src="https://dl.dropboxusercontent.com/u/20823269/kickster-token.png" alt="Screenshot of token generation in GitHub">
Copy the [automated](https://github.com/nielsenramon/kickster/blob/master/snippets/circle/automated) script inside the `/bin` folder of your project (check if the file has execute permissions!).

Copy the generated token.
#### 2. Update `circle.yml`

*Don't forget to enable your repository in [Travis CI](https://travis-ci.org/)*
Replace your `circle.yml` file with [this](https://github.com/nielsenramon/kickster/blob/master/snippets/circle/circle.yml) one. And adjust the following 2 lines with your information:

Go back to your project in terminal and input the following:
- USER_NAME: <your-github-username>
- USER_EMAIL: <your-github-email>

gem install travis
travis encrypt GITHUB_TOKEN=secret-token-from-github --add
#### 3. Enable Circle CI.

This added a line inside your `.travis.yml' file like this:
Make sure you enable your repository in Circle CI. In Circle CI go to `Project settings > Checkout SSH Keys` and create a new User key. This is required to push to the GitHub repo from a script (permissions).

secure: <encrypted token>
<img src="https://dl.dropboxusercontent.com/u/20823269/kickster-circle.jpg" alt="Screenshot of user key creating in Circle CI">

That's it, enjoy your automated deployments from now on!
That's it, start pushing changes and enjoy your automated deployments from now on!

## License

Expand Down
16 changes: 16 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
machine:
ruby:
version: 2.2.3

dependencies:
pre:
- gem build kickster.gemspec
- gem install kickster

test:
override:
- kickster new test
- ls -al
- cd test && bin/setup
- cd test && bundle exec jekyll build
- cd test && bundle exec htmlproof ./_site --only-4xx --href-ignore "#"
5 changes: 5 additions & 0 deletions lib/kickster/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ def copy_templates
directory("./", "./#{snake_name}")
end

def grant_permissions
chmod "./#{snake_name}/bin/deploy", 0755
chmod "./#{snake_name}/bin/setup", 0755
end

def report_success
say "Kickster template folder successfully created!", :green
end
Expand Down
2 changes: 1 addition & 1 deletion lib/kickster/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Kickster
VERSION = "1.0.4"
VERSION = "1.1.0"
end
41 changes: 0 additions & 41 deletions snippets/automated

This file was deleted.

43 changes: 43 additions & 0 deletions snippets/circle/automated
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

# Automated deploy script with Circle CI.

# Exit if any subcommand fails.
set -e

# Variables
ORIGIN_URL=`git config --get remote.origin.url`

echo "Started deploying"

# Checkout gh-pages branch.
if [ `git branch | grep gh-pages` ]
then
git branch -D gh-pages
fi
git checkout -b gh-pages

# Build site.
bower install
bundle exec jekyll build

# Delete and move files.
find . -maxdepth 1 ! -name '_site' ! -name '.git' ! -name '.gitignore' -exec rm -rf {} \;
mv _site/* .
rm -R _site/

# Push to gh-pages.
git config user.name "$USER_NAME"
git config user.email "$USER_EMAIL"

git add -fA
git commit --allow-empty -m "$(git log -1 --pretty=%B) [ci skip]"
git push -f $ORIGIN_URL gh-pages

# Move back to previous branch.
git checkout -
bower install

echo "Deployed Successfully!"

exit 0
21 changes: 21 additions & 0 deletions snippets/circle/circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
machine:
environment:
USER_NAME: <your-github-username>
USER_EMAIL: <your-github-email>
ruby:
version: 2.2.3

dependencies:
pre:
- ./bin/setup

test:
post:
- bundle exec jekyll build
- bundle exec htmlproof ./_site --only-4xx --href-ignore "#"

deployment:
production:
branch: master
commands:
- ./bin/automated
File renamed without changes.
47 changes: 47 additions & 0 deletions snippets/travis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Automated deploy with Travis CI
===============================

Kickster can also work with [Travis CI](https://travis-ci.org/), follow the steps below to set it up.

## Automated deployment with TravisCI

Automated deployment is by default not included in your Kickster generated Jekyll project. Please follow the steps below to include automated deployment with travis.

*Note that changes will only deploy when your code is merged into master.*

#### 1. Copy the required automated deploy script

Copy the [automated](https://github.com/nielsenramon/kickster/blob/master/snippets/travis/automated) script inside the `/bin` folder of your project (check if the file has execute permissions!).

#### 2. Add `.travis.yml`

Copy the `.travis.yml` from the [snippets](https://github.com/nielsenramon/kickster/blob/master/snippets/travis/.travis.yml) folder inside the `/bin` folder of your project(check if the file has execute permissions!).

And adjust the following 2 lines with your information:

- USERNAME: <your-github-username>
- EMAIL: <your-github-email>

#### 3. Create a personal access token

This is required to push to the GitHub repo from a script.

In GitHub go to `settings > Personal access tokens` and create a new one.
First give it a proper name so it is easy to recognize later. Then check `repo` (check `public_repo` if it is a public repository) and click on create.

<img src="https://dl.dropboxusercontent.com/u/20823269/kickster-token.png" alt="Screenshot of token generation in GitHub">

Copy the generated token.

*Don't forget to enable your repository in [Travis CI](https://travis-ci.org/)*

Go back to your project in terminal and input the following:

gem install travis
travis encrypt GITHUB_TOKEN=secret-token-from-github --add

This added a line inside your `.travis.yml' file like this:

secure: <encrypted token>

That's it, enjoy your automated deployments from now on!
45 changes: 45 additions & 0 deletions snippets/travis/automated
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

# Automated deploy script with Travis CI.

# Exit if any subcommand fails.
set -e

# Variables
ORIGIN_URL=`git config --get remote.origin.url`
ORIGIN_CREDENTIALS=${ORIGIN_URL/\/\/github.com/\/\/$GITHUB_TOKEN@github.com}
COMMIT_MESSAGE=$(git log -1 --pretty=%B)

echo "Started deploying"

# Checkout gh-pages branch.
if [ `git branch | grep gh-pages` ]
then
git branch -D gh-pages
fi
git checkout -b gh-pages

# Build site.
bower install
bundle exec jekyll build

# Delete and move files.
find . -maxdepth 1 ! -name '_site' ! -name '.git' ! -name '.gitignore' -exec rm -rf {} \;
mv _site/* .
rm -R _site/

# Push to gh-pages.
git config user.name "$USERNAME"
git config user.email "$EMAIL"

git add -fA
git commit --allow-empty -m "$COMMIT_MESSAGE [ci skip]"
git push -f -q $ORIGIN_CREDENTIALS gh-pages

# Move back to previous branch.
git checkout -
bower install

echo "Deployed Successfully!"

exit 0
11 changes: 0 additions & 11 deletions template/.travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions template/Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
source "https://rubygems.org"

gem "autoprefixer-rails", "~> 6.1.0.1"
gem "autoprefixer-rails", "~> 6.1.1"
gem "html-proofer", "~> 2.5.2"
gem "jekyll", "~> 3.0.1"
gem "jekyll-assets", "~> 2.0.2"
gem "jekyll-assets", "~> 2.0.3"
gem "jekyll-sitemap", "~> 0.9.0"
gem "sass", "~> 3.4.19"
gem "uglifier", "~> 2.7.2"
Empty file removed template/_assets/images/.keep
Empty file.
File renamed without changes
1 change: 1 addition & 0 deletions template/_config.yml.tt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ exclude:
- .travis.yml
- bin/*
- bower.json
- circle.yml
- Gemfile
- Gemfile.lock
- README.md
Expand Down
2 changes: 1 addition & 1 deletion template/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<meta name="twitter:description" content="{{ page.description }}">
<meta name="twitter:image" content="">

<link rel="apple-touch-icon" href="apple-touch-icon.png">
<link rel="apple-touch-icon" href="{% asset_path apple-touch-icon.png %}">

{% stylesheet application %}
</head>
Expand Down
Loading

0 comments on commit 0f13e27

Please sign in to comment.