Skip to content

Instantly share code, notes, and snippets.

@RemiBonnet
Created April 25, 2019 06:41
Show Gist options
  • Select an option

  • Save RemiBonnet/abf12c235607847102d41f52c7fa963d to your computer and use it in GitHub Desktop.

Select an option

Save RemiBonnet/abf12c235607847102d41f52c7fa963d to your computer and use it in GitHub Desktop.
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