爆速でSlack用のHubot作成からHerokuにデプロイするシェルスクリプト
Herokuにボットをいっぱい作りたいので、自動化スクリプトをつくってみました
- Slack用のHubot作成
- Herokuにデプロイ
必要なもの
- Herokuアカウント
- SlackのHUBOT_SLACK_TOKEN
スクリプト
make_hubot.sh
function install(){
if ! which $1 > /dev/null 2>&1 ; then brew install -g $1 ; fi
if ! which $1 > /dev/null 2>&1 ; then npm install -g $1 ; fi
}
function yo_hubot(){
expect -c "
set timeout -1
spawn yo hubot
expect \"Owner\"; send \"${HUBOT_NAME}\n\"
expect \"Bot name\"; send \"${HUBOT_NAME}\n\"
expect \"Description\"; send \"${HUBOT_NAME}\n\"
expect \"Bot adapter\"; send \"slack\n\"
expect \"Everything looks all right!\"; exit 0
"
}
HUBOT_NAME=my_hubot
HUBOT_SLACK_TEAM=my_team
export HUBOT_SLACK_TOKEN=xoxb-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
declare -a apps=("node" "npm" "hubot" "yo" "generator-hubot" "coffee-script" "redis" "expect")
for app in ${apps[@]}; do
echo $app
install $app
done
bot_dir=`pwd`/hubot-${HUBOT_NAME}
script_path=`pwd`/${HUBOT_NAME}.coffee
rm -rf $bot_dir
mkdir $bot_dir
cd $bot_dir
yo_hubot
rm hubot-scripts.json
# カレントディレクトリに`${HUBOT_NAME}.coffee`があれば設置
cp $script_path $bot_dir/scripts/${HUBOT_NAME}.coffee
redis-cli shutdown
redis-server &
ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
./bin/hubot --adapter slack
git init
git add .
git commit -m "init ${HUBOT_NAME}"
heroku login
heroku create $HUBOT_NAME
heroku config:set \
HUBOT_SLACK_TOKEN=$HUBOT_SLACK_TOKEN \
HUBOT_SLACK_TEAM=$HUBOT_SLACK_TEAM \
HUBOT_SLACK_BOTNAME=$HUBOT_NAME \
HUBOT_HEROKU_KEEPALIVE_URL=$(heroku apps:info -s | grep web_url | cut -d= -f2)
git push heroku master
heroku logs -t
実行
vi make_hubot.sh # ボット名やトークンを編集します
sh make_hubot.sh
make_hubot.sh
function install(){
if ! which $1 > /dev/null 2>&1 ; then brew install -g $1 ; fi
if ! which $1 > /dev/null 2>&1 ; then npm install -g $1 ; fi
}
function yo_hubot(){
expect -c "
set timeout -1
spawn yo hubot
expect \"Owner\"; send \"${HUBOT_NAME}\n\"
expect \"Bot name\"; send \"${HUBOT_NAME}\n\"
expect \"Description\"; send \"${HUBOT_NAME}\n\"
expect \"Bot adapter\"; send \"slack\n\"
expect \"Everything looks all right!\"; exit 0
"
}
HUBOT_NAME=my_hubot
HUBOT_SLACK_TEAM=my_team
export HUBOT_SLACK_TOKEN=xoxb-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
declare -a apps=("node" "npm" "hubot" "yo" "generator-hubot" "coffee-script" "redis" "expect")
for app in ${apps[@]}; do
echo $app
install $app
done
bot_dir=`pwd`/hubot-${HUBOT_NAME}
script_path=`pwd`/${HUBOT_NAME}.coffee
rm -rf $bot_dir
mkdir $bot_dir
cd $bot_dir
yo_hubot
rm hubot-scripts.json
# カレントディレクトリに`${HUBOT_NAME}.coffee`があれば設置
cp $script_path $bot_dir/scripts/${HUBOT_NAME}.coffee
redis-cli shutdown
redis-server &
ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
./bin/hubot --adapter slack
git init
git add .
git commit -m "init ${HUBOT_NAME}"
heroku login
heroku create $HUBOT_NAME
heroku config:set \
HUBOT_SLACK_TOKEN=$HUBOT_SLACK_TOKEN \
HUBOT_SLACK_TEAM=$HUBOT_SLACK_TEAM \
HUBOT_SLACK_BOTNAME=$HUBOT_NAME \
HUBOT_HEROKU_KEEPALIVE_URL=$(heroku apps:info -s | grep web_url | cut -d= -f2)
git push heroku master
heroku logs -t
実行
vi make_hubot.sh # ボット名やトークンを編集します
sh make_hubot.sh
vi make_hubot.sh # ボット名やトークンを編集します
sh make_hubot.sh
Author And Source
この問題について(爆速でSlack用のHubot作成からHerokuにデプロイするシェルスクリプト), 我々は、より多くの情報をここで見つけました https://qiita.com/___dera/items/4f71ccc452249e01150e著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .