jekyll-git-deploy 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +64 -0
- data/jekyll-git-deploy.gemspec +1 -1
- data/lib/helpers/common_tasks.rb +11 -0
- data/lib/jekyll_git_deploy.rb +29 -11
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a792c9d8b5cbacca308a02f042d8a83b36b5a8d
|
4
|
+
data.tar.gz: 04f2e047bec41b97c128dfddde4716af8ef8d301
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3ba5482ad01bef953ca5815c07699aace8ed24c645a180160ccdd771890b7aa32a16f167c3b9d77304f404239b13d0daf39ebbc25e7ca522e4a6d0b69f19f39
|
7
|
+
data.tar.gz: 0dc5af353cf756a653d79276bb198037c47d61ca5d2482eb7e0500e635240cc26c7a845c42c5b7b0a346b2fab2f802eb73986272321f717a3c817bfbbb6f0068
|
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
jekyll-git-deploy
|
2
|
+
========
|
3
|
+
Executable commands to help you to deploy your [jekyll](http://jekyllrb.com/) blog through git push way conveniently!
|
4
|
+
|
5
|
+
### Getting Started
|
6
|
+
1. Install The Gem
|
7
|
+
Install it through command line(recommended):
|
8
|
+
```sh
|
9
|
+
gem install jekyll-git-deploy
|
10
|
+
```
|
11
|
+
or, install it through the Gemfile:
|
12
|
+
```ruby
|
13
|
+
gem 'jekyll-git-deploy', '~> 0.0.1'
|
14
|
+
```
|
15
|
+
|
16
|
+
2. Config Additional Keys In Your `_config.yml` file:
|
17
|
+
```yaml
|
18
|
+
# #{site_root}/_config.yml
|
19
|
+
deploy_repo: git@something.com:martin/jekyll-deploy-demo.git
|
20
|
+
touch_file: Staticfile
|
21
|
+
deploy_branch: github-pages
|
22
|
+
deploy_remote_name: github
|
23
|
+
```
|
24
|
+
More details about these configs will be described later.
|
25
|
+
|
26
|
+
3. Initialize The Destination
|
27
|
+
Run the below command in the root of your jekyll site:
|
28
|
+
```sh
|
29
|
+
jekyll-git-deploy init
|
30
|
+
```
|
31
|
+
|
32
|
+
4. Deploy The Site
|
33
|
+
```sh
|
34
|
+
jekyll-git-deploy deploy
|
35
|
+
```
|
36
|
+
|
37
|
+
### More Details
|
38
|
+
#### 1. Supported Commands
|
39
|
+
Currently, `jekyll-git-deploy` supports its name as the main command and also two sub commands: `init` and `deploy`. They are mainly used to:
|
40
|
+
|
41
|
+
* `init`: Check and create destination directory for your deployment, and then check and initialize a git repo there
|
42
|
+
* `deploy`: Build the site using `jekyll build`, touch a specified file if necessary(some PaaS requires that a specifed name should be existed, they need that to detect a suitable running environment), create or checkout to deploy branch, commit changes and push them to specified repo and its branch.
|
43
|
+
|
44
|
+
#### 2. Supported Configs
|
45
|
+
`jekyll-git-deploy` dependent on five configs to work, the first one is `destination`, which is supported by jekyll itself already, here we use it to detect the target directory for generated site. The other four configs are:
|
46
|
+
|
47
|
+
| Config | Purpose | Default Value | Required |
|
48
|
+
| -------- | -------- | -------- | -------- |
|
49
|
+
| deploy_repo | Specify the deploy target, should be a remote git repo | NONE | YES |
|
50
|
+
| deploy_branch | Specify the deploy target branch | pages | NO |
|
51
|
+
| deploy_remote_name | Specify the remote name added to git, work with deploy_repo | deploy | NO |
|
52
|
+
| touch_file | Specify the file shoule be touched during a deployment | Staticfile | NO |
|
53
|
+
|
54
|
+
To see source codes, visit [Source codes for configs](./lib/helpers/common_tasks.rb).
|
55
|
+
|
56
|
+
### Contribute Guides
|
57
|
+
This project is just in its initial stage, more features or patches are welcome.
|
58
|
+
|
59
|
+
1. Fork this repo;
|
60
|
+
2. Clone your forked repo to your local file system;
|
61
|
+
3. Check out to a new branch;
|
62
|
+
4. Write and test your codes;
|
63
|
+
5. Commit and push your changes to a remote branch in your forked repo;
|
64
|
+
6. Submit a new PR.
|
data/jekyll-git-deploy.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'jekyll-git-deploy'
|
3
|
-
s.version = '0.0.
|
3
|
+
s.version = '0.0.2'
|
4
4
|
s.date = '2015-01-18'
|
5
5
|
s.summary = "Deploy jekyll site through git push"
|
6
6
|
s.description = "Executable commands to help you to deploy your jekyll blog through git push way conveniently!"
|
data/lib/helpers/common_tasks.rb
CHANGED
@@ -30,6 +30,17 @@ module CommonTasks
|
|
30
30
|
`git rev-parse --abbrev-ref HEAD`.strip
|
31
31
|
end
|
32
32
|
|
33
|
+
def checkout_target_branch(quiet = false)
|
34
|
+
unless current_branch == deploy_branch
|
35
|
+
puts "\nStart to checkout to deploy branch: #{deploy_branch}".yellow unless quiet
|
36
|
+
if `git show-branch #{deploy_branch} 2> /dev/null`.empty? # the deploy branch didn't exist
|
37
|
+
`git checkout -b #{deploy_branch}`
|
38
|
+
else
|
39
|
+
`git checkout #{deploy_branch}`
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
33
44
|
def self.included(base)
|
34
45
|
REQUIRED_CONFIGS.each do |method|
|
35
46
|
define_method method do
|
data/lib/jekyll_git_deploy.rb
CHANGED
@@ -15,7 +15,7 @@ module JekyllGitDeploy
|
|
15
15
|
raise "You haven't specify any deploy repo in _config.yml file, the action can not continue!".red
|
16
16
|
end
|
17
17
|
|
18
|
-
file = File.open('.gitignore', '
|
18
|
+
file = File.open('.gitignore', 'a+')
|
19
19
|
existed_line = file.readlines.select{|line| line.strip == destination}
|
20
20
|
unless existed_line
|
21
21
|
puts "\nadd #{destination} directory to .gitignore".yellow
|
@@ -37,6 +37,9 @@ module JekyllGitDeploy
|
|
37
37
|
puts "\nCurrent git remotes:\n==========================".yellow
|
38
38
|
puts `git remote -v`
|
39
39
|
|
40
|
+
puts "Fetch remote codes...".yellow
|
41
|
+
`git pull #{deploy_remote_name} #{deploy_branch}`
|
42
|
+
|
40
43
|
puts "\nFinished deploy initialization for the current site".green
|
41
44
|
end
|
42
45
|
end
|
@@ -44,6 +47,16 @@ module JekyllGitDeploy
|
|
44
47
|
# Build and push(deploy) the newest generated site
|
45
48
|
#
|
46
49
|
def deploy
|
50
|
+
# Pull the newest deploy data
|
51
|
+
Dir.chdir destination do
|
52
|
+
unless `git branch`.empty?
|
53
|
+
checkout_target_branch
|
54
|
+
|
55
|
+
puts "Updating remote deployed versions...".green
|
56
|
+
`git pull #{deploy_remote_name} #{deploy_branch}`
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
47
60
|
puts "\nGenerating the newest site".yellow
|
48
61
|
`jekyll build`
|
49
62
|
|
@@ -54,6 +67,7 @@ module JekyllGitDeploy
|
|
54
67
|
end
|
55
68
|
|
56
69
|
puts "\nruning `cd #{destination}`".yellow
|
70
|
+
|
57
71
|
Dir.chdir destination do
|
58
72
|
if `git branch`.empty? # Fully new git repo
|
59
73
|
commit_newest_site
|
@@ -61,20 +75,24 @@ module JekyllGitDeploy
|
|
61
75
|
puts "\nThis is a new git repo, creating new branch #{deploy_branch} now".yellow
|
62
76
|
`git checkout -b #{deploy_branch} &> /dev/null && git merge #{current_branch}`
|
63
77
|
else
|
64
|
-
|
65
|
-
puts "\nStart to checkout to deploy branch: #{deploy_branch}".yellow
|
66
|
-
if `git show-branch #{deploy_branch} 2> /dev/null`.empty? # the deploy branch didn't exist
|
67
|
-
`git checkout -b #{deploy_branch}`
|
68
|
-
else
|
69
|
-
`git checkout #{deploy_branch}`
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
78
|
+
checkout_target_branch
|
73
79
|
commit_newest_site
|
74
80
|
end
|
75
81
|
|
76
82
|
puts "\nPushing newest generated site:".yellow
|
77
|
-
`git push -u #{deploy_remote_name} #{deploy_branch}`
|
83
|
+
push_result = `git push -u #{deploy_remote_name} #{deploy_branch} 2>&1`
|
84
|
+
if push_result.include?("Updates were rejected because the remote contains work")
|
85
|
+
print "Oops! It seems there are some updates exist in the remote repo so that your pushing has been rejected, do you want to force to update?[Y/N]".red
|
86
|
+
if STDIN.gets.chomp.to_s.downcase == 'y'
|
87
|
+
puts "Try to force to update remote repo...".yellow
|
88
|
+
`git push -f #{deploy_remote_name} #{deploy_branch}`
|
89
|
+
else
|
90
|
+
puts "You have canceled the deploy process, you need to manually merge remote updates before deploy!".yellow
|
91
|
+
exit
|
92
|
+
end
|
93
|
+
else
|
94
|
+
puts push_result
|
95
|
+
end
|
78
96
|
|
79
97
|
puts "\nThe deploy is finished!".green
|
80
98
|
baseurl = read_configs['baseurl'] || ""
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-git-deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Hong
|
@@ -18,7 +18,8 @@ executables:
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
-
- .gitignore
|
21
|
+
- ".gitignore"
|
22
|
+
- README.md
|
22
23
|
- bin/jekyll-git-deploy
|
23
24
|
- jekyll-git-deploy.gemspec
|
24
25
|
- lib/helpers/common_tasks.rb
|
@@ -34,18 +35,19 @@ require_paths:
|
|
34
35
|
- lib
|
35
36
|
required_ruby_version: !ruby/object:Gem::Requirement
|
36
37
|
requirements:
|
37
|
-
- -
|
38
|
+
- - ">="
|
38
39
|
- !ruby/object:Gem::Version
|
39
40
|
version: '0'
|
40
41
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
42
|
requirements:
|
42
|
-
- -
|
43
|
+
- - ">="
|
43
44
|
- !ruby/object:Gem::Version
|
44
45
|
version: '0'
|
45
46
|
requirements: []
|
46
47
|
rubyforge_project:
|
47
|
-
rubygems_version: 2.
|
48
|
+
rubygems_version: 2.4.8
|
48
49
|
signing_key:
|
49
50
|
specification_version: 4
|
50
51
|
summary: Deploy jekyll site through git push
|
51
52
|
test_files: []
|
53
|
+
has_rdoc:
|