快樂小碼農

{happy coder}

Build Status

| Comments

Build Status

1
[![Build Status](https://travis-ci.com/copy0401/copy0401.github.io.svg?branch=source)](https://travis-ci.com/copy0401/copy0401.github.io)

prose.io Edit

Travis CI

| Comments

Set Up SSH Keys (for repo deploy)

1
ssh-keygen -t rsa -b 4096 -C "copy0401@gmail.com"

1./Users/電腦使用者名稱/.ssh/id_rsa_deploy

2.輸入密碼 留白 Enter

3.再次輸入密碼 留白 Enter

會產生一組金鑰

公鑰: id_rsa_deploy.pub

私鑰: id_rsa_deploy

( 私鑰base64編碼: id_rsa_deploy_base64 後面會介紹 )


github repo add deploy key

in copy0401/copy0401.github.io

Settings > Deploy keys > add deploy key

Title: travis deploy

Key: 填入 id_rsa_deploy.pub 公鑰內容

1
ssh-rsa AAAAB3NzaC1yc2EA...gzR7LH/iSxYwxSbb9+Q== copy0401@gmail.com

github token (public_repo)

github.com > your_settings >Developer settings > Personal access tokens > Generate new token

note: Travis access

Select scopes : public_repo

Generate token = > 123a1c1ed1dfa1fc1234b123456a12abd1234567


GH_TOKEN

1
gem install travis
1
travis encrypt 'GH_TOKEN=123a1c1ed1dfa1fc1234b123456a12abd1234567' --add

or

1
travis encrypt 'GIT_NAME="copy0401" GIT_EMAIL=copy0401@gmail.com GH_TOKEN=123a1c1ed1dfa1fc1234b123456a12abd1234567' --add

.travis.yml 中增加 GH_TOKEN=[secure]

1
2
travis login --pro  --auto
travis encrypt SOMEVAR="secretvalue" --add

.travis.yml 中增加 SOMEVAR=[secure]


To generate secure SSH deploy key for a github repo to be used from Travis

參考: https://gist.github.com/floydpink/4631240

1
base64 --break=0 ~/.ssh/id_rsa_deploy > ~/.ssh/id_rsa_deploy_base64

id_rsa_deploy 轉換為base64編碼為 id_rsa_deploy_base64

1
ENCRYPTION_FILTER="echo \$(echo \"- secure: \")\$(travis encrypt \"\$FILE='\`cat $FILE\`'\" -r copy0401/copy0401.github.io)"
1
2
brew install coreutils 
gsplit --bytes=100 --numeric-suffixes --suffix-length=2 --filter="$ENCRYPTION_FILTER" ~/.ssh/id_rsa_deploy_base64 id_rsa_

會產生約46行內容 貼到 .travis.yml 最後面 注意格式,前面加 -

1
2
3
4
5
6
7
8
9
env:
  global:
  - secure: "rpdVrWM...xtOuONAE="
  - secure: "aJGiNmI...nzpD62Sk="
  - secure: "O1rEHB...Yu+xXGFQc="
    .
    .
    .
  - secure: "O1rEHB...pDCdFd3d="

修改 .travis.yml 內容 在 before_script: 下面增加這幾行內容

1
2
3
4
5
before_script:
  - echo -n $id_rsa_{00..30} >> ~/.ssh/id_rsa_base64
  - base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
  - chmod 600 ~/.ssh/id_rsa
  - echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config

.travis.yml

1
2
3
4
5
6
7
8
9
10
11
12
env:
  global:
  - GH_REPO="copy0401/copy0401.github.io" # 依照自己的 github_name/github_repo 設定
  - secure: "rpdVrWM...xtOuONAE=" # 解析後就是 GH_TOKEN 
  - secure: "x87sdje...in0xdase=" # 解析後就是 SOMEVAR
  - secure: "aJGiNmI...nzpD62Sk=" # 解析後就是 id_rsa_00
  - secure: "O1rEHB...Yu+xXGFQc=" # 解析後就是 id_rsa_01
  - secure: "nzpD6ec...xtOuONAE=" # 解析後就是 id_rsa_02
   .
   .
   .
  - secure: "nzpD6ec...xtOuONAE=" # 解析後就是 id_rsa_45
1
2
3
travis encrypt 'GH_TOKEN=123a1c1ed1dfa1fc1234b123456a12abd1234567' --add
travis encrypt SOMEVAR="secretvalue" --add
gsplit --bytes=100 --numeric-suffixes --suffix-length=2 --filter="$ENCRYPTION_FILTER" ~/.ssh/id_rsa_deploy_base64 id_rsa_

修改內容 .travis.yml

Set Octopress

| Comments

Disqus 申請帳號

登入Disqus帳號

點選 右上頭像 > 點選 Settings

點選 右上頭像 > 點選 Add Disqus To Site

點選 Start Using Engage

Site name 輸入留言板的名字

如: copy0401

Choose your unique Disqus URL 輸入留言版的網址

如: http://disqus.com/by/copy0401

Category 選擇類別

如: Tech

1
2
3
4
cd ~/octopress
vim _config.yml
disqus_short_name: copy0401
disqus_show_comment_count: true

Set Octopress Theme

| Comments

1
2
3
4
5
cd ~/octopress
git clone git://github.com/lucaslew/whitespace.git .themes/whitespace
rake install['whitespace'] # for zsh, use: rake install\['whitespace'\]
rake generate
rake preview
1
rake setup_github_pages

git@github.com:[your_username]/[your_username].github.io.git

例如輸入

1
git@github.com:copy0401/copy0401.github.io
1
2
rake generate
rake deploy

Install Octopress

| Comments

1
2
3
4
5
6
7
cd ~/
git clone git://github.com/imathis/octopress.git octopress
cd octopress
gem install bundler
bundle install
rake install
rake preview

http://localhost:4000/

1
rake setup_github_pages

git@github.com:[your_username]/[your_username].github.io.git

例如輸入

1
git@github.com:copy0401/copy0401.github.io
1
2
3
rake generate
rake preview
rake deploy

新的頁面

1
rake new_page["title"] # for zsh, use: rake new_page\["title"\]

or

1
rake new_page[about/index.html] # for zsh, use: rake new_page\[about/index.html\]

再去 source/_includes/custom/navigation.html 新增連結

1
2
3
4
5
6
<ul class="main-navigation">
  <li><a href="/">Blog</a></li>
  <li><a href="/blog/categories/octopress/">Octopress</a></li>
  <li><a href="/blog/archives">Archives</a></li>
  <li><a href="/about">About</a></li>
</ul>

撰寫文章

1
rake new_post["title"]

產生新的檔案 YYYY-MM-DD-title.markdownsource/_posts/

如果 .markdown 要改成 .md 可以到修改 Rakefile

1
2
new_post_ext    = "md"
new_page_ext    = "md"

Push to Github

1
2
3
git add .
git commit -m "some commit"
git push origin source