This repository has been archived by the owner on Aug 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
125 additions
and
32 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import * as fs from 'fs'; | ||
import * as needle from 'needle'; | ||
|
||
const GITHUB_TOKEN = process.env.GITHUB_TOKEN; | ||
|
||
const eventName = process.env.GITHUB_EVENT_NAME; | ||
if (eventName !== 'pull_request') { | ||
process.exit(1); | ||
} | ||
|
||
const eventPath = process.env.GITHUB_EVENT_PATH; | ||
if (!eventPath) { | ||
console.log('Couldn\'t find the event file path.'); | ||
process.exit(1); | ||
} | ||
|
||
const eventData = fs.readFileSync(eventPath, 'utf8'); | ||
const eventObj = JSON.parse(eventData); | ||
console.log(eventObj); | ||
|
||
async function postComment(issueUrl: string): Promise<void> { | ||
const url = `${issueUrl}/comments`; | ||
const payload = { | ||
body: 'There\'s butter on my face!', | ||
}; | ||
const options = { | ||
json: true, | ||
compressed: true, | ||
headers: { | ||
Authorization: 'token ' + GITHUB_TOKEN, | ||
}, | ||
}; | ||
|
||
try { | ||
await needle('post', url, payload, options); | ||
console.log('huzzah!'); | ||
} catch (err) { | ||
console.log('I have no idea what I\'m doing'); | ||
} | ||
} | ||
|
||
const issueUrl = eventObj.pull_request.issue_url; | ||
postComment(issueUrl); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"compilerOptions": { | ||
"outDir": "./dist", | ||
"incremental": true, | ||
"target": "es2018", | ||
"module": "commonjs", | ||
"sourceMap": true, | ||
"pretty": true, | ||
"importHelpers": true, | ||
"strict": true, | ||
"noImplicitAny": true, | ||
"noUnusedLocals": true, | ||
"resolveJsonModule": true, | ||
"noImplicitReturns": true | ||
}, | ||
"include": [ | ||
"./src/**/*" | ||
] | ||
} |