LoginSignup
16
13

More than 5 years have passed since last update.

GitHub PagesとGitLab Pagesの比較

Last updated at Posted at 2017-05-17

(2017/06/29 追記) 後半は利用可能なデプロイツールの比較になってますね。

GitHub GitLab
SSL 対応 対応
独自ドメインSSL 非対応 対応
デプロイツール Circle CI, Travis CI, ... GitLab CI
デプロイ方法 gh-pages にプッシュ tarをアップロード
環境変数の隠蔽 ペアリング暗号 GUIで設定

GitLab CI設定ファイル

詰まったところを交えつつ書いていきます。

.gitlab-ci.yml
image: node:latest
stages:
  - deploy
cache:
  # NPMに関連するディレクトリをキャッシュすることでインストールを高速化
  paths:
    - node_modules/
    - .yarn/
pages:
  stage: deploy
  # masterブランチにプッシュされた時のみ実行
  only:
    - master
  before_script:
    # Yarnのキャッシュディレクトリを .yarn に
    - 'yarn config set cache-folder .yarn'
    - 'yarn install'
  script:
    # スクリプトで gulp タスクを回しビルドを実行
    - 'yarn run build'
    # どうやらアップロードするディレクトリは public という名前である必要がある
    - 'cp -pr build public'
  after_script:
    # デプロイ後にCloudFlareのキャッシュを消去
    - './cf-cache-flush.sh'
  artifacts:
    paths:
      - public
variables:
  # shallow cloneすることによりダウンロードを高速化
  GIT_DEPTH: '1'
  CF_ZONE_ID: '26c20487321750ddce766cc1a83a6afa'
cf-cache-flush.sh
#!/bin/sh

# CloudFlareのキャッシュを削除
# $CF_API_KEY は隠蔽する必要があるので、GUIの Secret Variables で定義する
curl -X DELETE "https://api.cloudflare.com/client/v4/zones/${CF_ZONE_ID}/purge_cache" \
  -H "X-Auth-Email: sei40kr@gmail.com" \
  -H "X-Auth-Key: ${CF_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"purge_everything":true}'

こちらもどうぞ

16
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
13