www.gentoo.jpのGithub Pagesについて

  GentooJPのGithub Pagesの管理方法について説明します。




Contents:

1. Github Pagesについて

2. コンテンツ作成方法

3. コンテンツの提出方法

Author : GentooJP


Updated 2 Mar 2014




1.Github Pagesについて

Github PagesはGithubが提供するホスティングサービスです。 GentooJPのホームページのリポジトリはhttps://github.com/gentoojp/gentoojp.github.ioです。

コンテンツ管理はOctopressを使用しています。 travis-ci経由で自動的にデプロイされます。

2.コンテンツ作成方法

リポジトリのチェックアウト 

Github上でリポジトリをフォークしてください。ここでは nabeken アカウントにフォークしたとします。

Code listing 2.1: フォークしたリポジトリをcloneする
$ git clone git@github.com:nabeken/gentoojp.github.io.git
$ cd gentoojp.github.io

octopress環境の準備 

Important: Rubyを事前にインストールしておいてください。最新版(執筆時点で2.1.0)が望ましいです。

Code listing 2.2: Octopressのインストール
$ bundle install

記事の作成 

例としてGentooJPのニュースの記事を作成してみます。

Code listing 2.3: ニュース記事を作成
$ $EDITOR source/jpnews/main/20140301-github-pages.xml
<?xml version='1.0'?>
<?xml-stylesheet href="/xsl/guide.xsl" type="text/xsl"?>
<news gentoo="yes" category="gentoojp">
  <poster>nabeken</poster>
  <date>1 Mar 2014</date>
  <title>Github Pagesへ移行しました</title>
<body>
  <p>
    GentooJPのホームページ(www.gentoo.jp)はGithub Pagesへ移行しました。
  </p>
</body>
Code listing 2.4: ニュース記事をRSS用インデックスに追加
$ $EDITOR source/jpnews/main/news-index.xml
<uri>/jpnews/main/20140301-github-pages.xml</uri> // 一番上に追記します
Code listing 2.5: 記事を確認する
$ bundle exec rake generate
$ bundle exec rake preview
$ open http://localhost:4000/jpnews/main/20140301-github-pages.html

preview中はファイルの変更を自動的に検知し、再作成してくれます。

3.コンテンツの提出方法

Pull Request経由の場合 

Code listing 3.1: 作成した記事をコミット
$ git add source/jpnews/main/news-index.xml source/jpnews/main/20140301-github-pages.xml
$ git commit -m 'jpnews: Add news about github pages'
$ git push

pushした後はGithub上からPull Requestしてください。自動的にtravis-ciで構文チェック、ビルドを実行します。

travis-ciがパスし、GentooJP開発者によるレビューにパスすればマージされます。

直接更新する場合 

Githubのgentoojp organizationメンバーは特別な事情がある場合に限り、直接更新できます。 直接更新する場合予めデプロイ用のディレクトリを作成する必要があります。

Code listing 3.2: 直接デプロイする
$  git clone git@github.com:gentoojp/gentoojp.github.io.git _deploy
$ (cd _deploy && git checkout -b master origin/master)
$ bundle exec rake generate deploy
Copyright© 2002-2014 Gentoo Linux Users Group Japan. All rights reserved.

このサイトはGentooJPが運営するGentoo.org非公式コミュニティサイトです。ご質問、ご意見などはこちらまで。 Email: www@gentoo.gr.jp