Skip to content

Instantly share code, notes, and snippets.

@laurentades
Forked from abaez/codebase.lua
Last active November 9, 2016 01:49
Show Gist options
  • Save laurentades/5857421e4a2e5987da6e104daad73582 to your computer and use it in GitHub Desktop.
Save laurentades/5857421e4a2e5987da6e104daad73582 to your computer and use it in GitHub Desktop.
Codebase webscript for slack
--- making an example to push to webscript
local icon = "https://pbs.twimg.com/profile_images/378800000410745178/8704302b5009e71d66fbc8f52cefc0bc_400x400.png"
local link = "https://talks.slack.com/services/hooks/incoming-webhook?token="
local token = ""
local fi = json.parse(request.form.payload)
local fo = {
user_email = fi.user.email,
user = fi.user.name,
commit = fi.commits[1].id,
commit_msg = fi.commits[1].message,
commit_url = fi.commits[1].url,
repo = fi.repository.name,
repo_url = fi.repository.url,
}
text = string.format("%s committed to <%s|%s>", fo.user, fo.repo_url, fo.repo)
push = {
username = "codebase",
channel = "#activity",
icon_url = icon,
text = text,
attachments = {{
fallback = text,
color = "good",
fields = {{
title = "changeset: ",
value = string.format("<%s|%s>: %s", fo.commit_url, fo.commit, fo.commit_msg),
short = "false"
},}
},}
}
return http.request{
method = "POST",
headers = {
["Content-Type"] = "application/json",
},
url = link .. token,
-- url = "http://requestb.in/",
data = json.stringify(push)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment