0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Deployer でつまづいたポイント(Windows 10+さくらレンタルサーバー+GitHub)

Last updated at Posted at 2018-03-20

つまづきポイント :no_pedestrians:

  1. sshコマンドが使えるターミナルからdeployすること
    • 素のcmd.exeとかでは :no_good_tone1:
    • 筆者は :octocat: GitHub Desktop 同梱の Git Shellを使用しました
  2. ssh user@domain.sakura.ne.jp -i ~/.ssh/id_rsaでサーバーにログインできる状態であること
    • userdomainは適宜自分のものに書き換える
    • ~/.ssh/id_rsaは後述のdeploy.phpidentityFileに指定する秘密鍵とおなじもの
  3. サーバー側に最新のGitをインストールし

deploy.php

最終的に以下のようになりました。

<?php
namespace Deployer;

require 'recipe/common.php';

// Hosts
host('user@domain.sakura.ne.jp')
    ->port(22)
    ->addSshOption('UserKnownHostsFile', '/dev/null')
    ->addSshOption('StrictHostKeyChecking', 'no')
    ->identityFile('~/.ssh/id_rsa')
    ->forwardAgent(true)
    ->multiplexing(false)
    ->set('deploy_path', '~/www/path/of/project')
    ->set('bin/git', '~/local/bin/git')
    ->set('application', 'project-name-here')
    ->set('repository', 'git@github.com:your/project.git')
    ;

// Tasks

desc('Deploy your project');
task('deploy', [
    'deploy:info',
    'deploy:prepare',
    'deploy:lock',
    'deploy:release',
    'deploy:update_code',
    'deploy:shared',
    'deploy:writable',
    'deploy:vendors',
    'deploy:clear_paths',
    'deploy:symlink',
    'deploy:unlock',
    'cleanup',
    'success'
]);

// [Optional] If deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');

> php deployer.phar deploy

すべてがうまくいったとき
✈︎ Deploying master on user@domain.sakura.ne.jp
➤ Executing task deploy:prepare
✔ Ok
➤ Executing task deploy:lock
✔ Ok
➤ Executing task deploy:release
✔ Ok
➤ Executing task deploy:update_code
✔ Ok
➤ Executing task deploy:shared
✔ Ok
➤ Executing task deploy:writable
✔ Ok
➤ Executing task deploy:vendors
✔ Ok
➤ Executing task deploy:clear_paths
✔ Ok
➤ Executing task deploy:symlink
✔ Ok
➤ Executing task deploy:unlock
✔ Ok
➤ Executing task cleanup
✔ Ok
Successfully deployed!

それでもエラーが出たら

-vvvオプションで実行してみる

php deployer.phar deploy -vvv
ステップのログが細かく出力されるので、どの部分で失敗しているのかが特定できるかもしれません。

deployerレポジトリをcloneしてコード読んでみる。

PHPコードなので、読めないことはないという気持ちがたいせつ。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?