Last active
August 29, 2015 13:59
-
-
Save mbmccormick/10931764 to your computer and use it in GitHub Desktop.
Create GitHub issues from email, using Webscript and Postmark
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local ACCESS_TOKEN = 'YOUR_PERSONAL_ACCESS_TOKEN' | |
local USERNAME = 'YOUR_GITHUB_USERNAME' | |
-- import Microlight lua library | |
local ml = require('mbmccormick/Microlight/ml.lua') | |
-- parse inbound request from Postmark service | |
local data = json.parse(request.body) | |
local subject = data.Subject | |
local body = data.TextBody | |
-- parse subjects like 'Milkman Error Report' | |
local parts = ml.split(subject) | |
local repository = parts[1] | |
-- trim the issue title to the first 140 characters | |
local title = body | |
title = string.sub(title, 1, 140) | |
-- create issue on GitHub | |
local response = http.request { | |
url = 'https://api.github.com/repos/' .. USERNAME .. '/' .. repository .. '/issues', | |
method = 'POST', | |
data = json.stringify({ | |
title = title, | |
body = body | |
}), | |
auth = { | |
ACCESS_TOKEN, | |
'x-oauth-basic' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment