LoginSignup
0
0

More than 3 years have passed since last update.

【heroku デプロイ】アプリ新規作成と更新のやり方

Posted at

【heroku デプロイ】新規と更新のやり方

herokuを使えば、コードを定期実行することができます。
無料なので、botとか作りたい時にオススメ。

備忘録としてメモ書き。

筆者もちょいちょい忘れることが多いので、
折角なので新規と更新のやり方をまとめることにした。

なお、更新は、たったの2行で済む

terminal
$heroku login
$git push heroku master

デプロイ・新規

まずはインストール済かどうか確認

terminal
$git --version
$heroku -v

gitをインストール

herokuをインストール

terminal
$brew tap heroku/brew && brew install heroku

herokuにログイン

terminal
$heroku login

ブラウザでherokuのログイン画面が自動で立ち上がるので
ユーザー名とパスワードを入力してログイン。

herokuにアプリを作成

terminal
$heroku create アプリ名(重複作成できない)

ここで出力される***.gitをメモしておくこと。

runtime.txtとrequirements.txtを作成

runtime.txt
python-3.9.1
requirements.txt
appnope==0.1.2
argon2-cffi==20.1.0
asgiref==3.3.1
async-generator==1.10
attrs==20.3.0
autopep8==1.5.4
backcall==0.2.0
beautifulsoup4==4.9.3
bleach==3.2.1
bs4==0.0.1
cachetools==4.1.1
certifi==2020.11.8
////(省略)

herokuへアプリをデプロイ

terminal
$git init
$git remote add heroku (先程メモした***.git)
$git add .
$git commit -m "(メッセージ・コミット内容)"
$git push heroku master

これにてデプロイ完了。

Heroku Schedulerの設定

定時実行のHeroku Schedulerの設定を行う。

terminal
$heroku addons:add scheduler:standard
$heroku addons:open scheduler

ブラウザが開かれて設定。
※UTCが基準になっているため設定する時間は、
実行したい時間-9時間となるように設定すること。

デプロイ・更新

変更分をGitHubデスクトップでcommit,push。

herokuへログイン。

terminal
$heroku login

herokuにデプロイ。

terminal
$git push heroku master
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