The plugin provides endpoint for triggering the deployment process. The classing use case is a self hosted CMS, Drupal or Wordpress, and a gatsby site which pull data from the CMS. Now, how does the cotent authors in the site will deploy the site to Github pages, or to S3?
If you still think on a solution - you are in the correct place. The plugin expose a REST endpoint for trigger the
npm run deploy
command. The endpoint requires a secret key inorder to prevent from anyone to deploy your site.
npm install --save gatsby-plugin-trigger-deploy
// In your gatsby-config.js
module.exports = {
plugins: [
{
resolve: `gatsby-plugin-trigger-deploy`,
options: {
secretKey: 'a super secret key, maybe with emojis? 🍕',
addressCallback: 'http://localhost/endpoint/for/notifying',
},
},
],
}
In order to trigger the deployment you'll need to send a request similar to this:
var axios = require('axios');
var config = {
method: 'post',
url: 'http://localhost:8000/deploy',
headers: {
'secret_key': 'a super secret key, maybe with emojis? 🍕',
}
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
- secretKey - Required; The secret key which is required for triggering the deployment process.
- addressCallback - Optional; If defined, the plugin will send REST request with data on the deployment process.