LoginSignup
7
12

More than 3 years have passed since last update.

【備忘録】GitHub経由でHerokuにデプロイするまでの流れ

Posted at

大まかな流れ

1.GitHubにリモートリポジトリをつくる
2.ローカルリポジトリをつくり、リモートリポジトリにプッシュ
3.HerokuにAppをつくり、GitHubと連携

GitHubにリモートリポジトリをつくる

image.png

ローカルリポジトリをつくり、リモートリポジトリにプッシュ

ターミナルを開き、ローカルリポジトリをつくるディレクトリに移動し、下記コマンドを打つ。

git init
git commit -m "初回コミット"
git remote add origin https://github.com/{GitHubのユーザー名}/{リモートリポジトリ名}.git
git push -u origin master

やってること

①git init:ローカルリポジトリをつくる
②git add:ディレクトリやファイルをインデックスに登録
③git commit:変更をローカルリポジトリにコミット
④git push:リモートリポジトリにプッシュ

HerokuにAppをつくり、GitHubと連携

①「Create new app」をクリックし、次の画面でApp名を指定して「Create App」をクリック。
image.png

②Setting>Buildpacksで開発言語に合わせたBuild Packを選択。
image.png

③Deploy>Deployment methodの「GitHub」をクリック(下図赤枠)。
image.png

④GitHubでつくったリモートリポジトリを検索し、「Connect」をクリック。
image.png

⑤Deploy>Automatic deploysの「Wait for CI to pass before deploy」にチェックを入れ、「Enable Automatic Deploys」をクリック。※
その後、Deploy>Manual deployの「Choose a branch to deploy」がmasterになっていることを確認したうえで「Deploy Branch」をクリック、手動Buildする。
image.png
※ チェックを入れるとDeploy前にHeroku CIが動き、自動的にソースコード内で設定されたユニットテストが実行される。
  そのテストコードがすべてパスしたら、Deployするフローとなる。

参考にさせて頂いた記事

heroku 初級編 - GitHub から deploy してみよう -

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