Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

手动给 mina 部署增加通知推送到 bearychat #2

Open
fushang318 opened this issue Sep 1, 2016 · 0 comments
Open

手动给 mina 部署增加通知推送到 bearychat #2

fushang318 opened this issue Sep 1, 2016 · 0 comments

Comments

@fushang318
Copy link
Contributor

创建 bearychat incoming 机器人,复制 hook 地址

创建并编写 bearychat_incoming.sh 脚本

ssh 连接服务器,进入部署的 rails 程序目录,创建 shared/deploy/sh/bearychat_incoming.sh

touch shared/deploy/sh/bearychat_incoming.sh
chmod +x shared/deploy/sh/bearychat_incoming.sh

复制如下内容到文件,并进行适当的修改

#!/bin/bash

webhook_url="https://hook.bearychat.com/=bw8WG/incoming/e5b3a02bef73b9092794124df29959a5"

text="kc 已经部署新的版本"

title="访问地址"
url="https://kc.com/"
color="#40B5F0"

json="
{
  \"text\": \"$text\",
  \"attachments\": [
    {
      \"title\": \"$title\",
      \"text\": \"$url\",
      \"color\": \"$color\"
    }
  ]
}
"

curl $webhook_url \
  -H 'Content-Type: application/json' \
  -d "$json"

修改 config/deploy.rb 文件

本地打开 config/deploy.rb
增加两行配置

set :shared_paths, [
  # 增加这一行
  'deploy/sh/bearychat_incoming.sh'
]

task :deploy => :environment do

  deploy do
    invoke :'git:clone'
    invoke :'deploy:link_shared_paths'
    to :launch do
      queue %[
        source /etc/profile
        bundle
        cnpm install
        RAILS_ENV=production bundle exec rake assets:precompile
        ./deploy/sh/unicorn.sh stop
        ./deploy/sh/unicorn.sh start

        # 增加这一行
        ./deploy/sh/bearychat_incoming.sh    

      ]
    end
  end

end

修改完提交到版本库

下次运行 bundle exec mina deploy 部署后就会发送通知到 bearychat 了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant