Skip to content

Instantly share code, notes, and snippets.

@mbmccormick
Last active August 29, 2015 13:59
Show Gist options
  • Save mbmccormick/10931764 to your computer and use it in GitHub Desktop.
Save mbmccormick/10931764 to your computer and use it in GitHub Desktop.
Create GitHub issues from email, using Webscript and Postmark
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