Created
April 25, 2019 06:41
-
-
Save RemiBonnet/abf12c235607847102d41f52c7fa963d to your computer and use it in GitHub Desktop.
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
| const https = require('https'); | |
| exports.handler = async (event, context) => { | |
| return new Promise((resolve, reject) => { | |
| const options = { | |
| hostname: 'api.travis-ci.org', | |
| path: `/repo/${process.env.TRAVIS_CLIENT_NAME}%2F${process.env.TRAVIS_REPO_NAME}/requests`, | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| 'Accept': 'application/json', | |
| 'Travis-API-Version': 3, | |
| 'Authorization': `token ${process.env.TRAVIS_API_KEY}` | |
| } | |
| }; | |
| const post_data = JSON.stringify({ | |
| request: { | |
| branch: "master" | |
| } | |
| }); | |
| const req = https.request(options, (res) => { | |
| resolve('Success'); | |
| }); | |
| req.on('error', (e) => { | |
| reject(e.message); | |
| }); | |
| // send the request | |
| req.write(post_data); | |
| req.end(); | |
| }); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment