2019-03-06 02:08:02 +08:00
|
|
|
#!/usr/bin/env node
|
|
|
|
/* eslint-disable no-console */
|
|
|
|
|
|
|
|
const fetch = require('node-fetch');
|
2020-02-12 21:01:24 +01:00
|
|
|
const { execSync } = require('child_process');
|
2019-03-06 02:08:02 +08:00
|
|
|
|
2020-02-12 21:01:24 +01:00
|
|
|
const { FRONTPAGE_WEBHOOK } = process.env;
|
|
|
|
|
2020-03-27 20:04:50 +01:00
|
|
|
const branch = execSync('git rev-parse --abbrev-ref HEAD').toString().trim();
|
2019-03-06 02:08:02 +08:00
|
|
|
|
|
|
|
console.log('build-frontpage');
|
2020-02-12 21:01:24 +01:00
|
|
|
if (branch === 'master') {
|
2019-03-06 02:08:02 +08:00
|
|
|
if (FRONTPAGE_WEBHOOK) {
|
|
|
|
console.log('triggering frontpage build');
|
|
|
|
const url = `https://api.netlify.com/build_hooks/${FRONTPAGE_WEBHOOK}`;
|
2020-03-27 20:04:50 +01:00
|
|
|
fetch(url, { method: 'post' }).then((res) => console.log('result', res.status));
|
2019-03-06 02:08:02 +08:00
|
|
|
} else {
|
|
|
|
console.log('no webhook defined');
|
|
|
|
}
|
|
|
|
} else {
|
2020-02-12 21:01:24 +01:00
|
|
|
console.log('skipping branch', branch);
|
2019-03-06 02:08:02 +08:00
|
|
|
}
|