Verified Commit 0c92ff86 authored by Aral Balkan's avatar Aral Balkan
Browse files

Limit deployment to the master git branch

parent a1d52736
...@@ -32,6 +32,8 @@ const cpuArchitecture = os.arch() ...@@ -32,6 +32,8 @@ const cpuArchitecture = os.arch()
// Parse the command-line arguments. // Parse the command-line arguments.
const commandLineOptions = minimist(process.argv.slice(2), {boolean: true}) const commandLineOptions = minimist(process.argv.slice(2), {boolean: true})
const mainSourceDirectory = path.join(__dirname, '..')
// Display help on syntax error or if explicitly requested. // Display help on syntax error or if explicitly requested.
if (commandLineOptions._.length !== 0 || commandLineOptions.h || commandLineOptions.help) { if (commandLineOptions._.length !== 0 || commandLineOptions.h || commandLineOptions.help) {
console.log('\n Usage: npm run build [--deploy] [--all] [--install] [--alpha] [--beta] [--update-nexe]\n') console.log('\n Usage: npm run build [--deploy] [--all] [--install] [--alpha] [--beta] [--update-nexe]\n')
...@@ -53,11 +55,23 @@ if (commandLineOptions.deploy && childProcess.execSync('git status').toString(). ...@@ -53,11 +55,23 @@ if (commandLineOptions.deploy && childProcess.execSync('git status').toString().
const websitePath = path.resolve(path.join(__dirname, '..', '..', 'site')) const websitePath = path.resolve(path.join(__dirname, '..', '..', 'site'))
if (commandLineOptions.deploy && !fs.existsSync(websitePath)) { if (commandLineOptions.deploy) {
// Ensure that a working copy of the Site.js web site exists
// locally where we ex[ect it to so we can deploy to it.
if (!fs.existsSync(websitePath)) {
console.log('❌ Error: No local working copy of Site.js web site found.\n') console.log('❌ Error: No local working copy of Site.js web site found.\n')
console.log(` Please clone https://small-tech.org/site.js/site to ${websitePath}`) console.log(` Please clone https://small-tech.org/site.js/site to ${websitePath}`)
console.log(' (and ensure you have commit permissions on the repository) before attempting to deploy.\n') console.log(' (and ensure you have commit permissions on the repository) before attempting to deploy.\n')
process.exit(1) process.exit(1)
}
// Ensure that we are on the master branch.
// (Deployments are only allowed from the master branch.)
const gitBranch = childProcess.execSync('git branch --show-current', {env: process.env, cwd: mainSourceDirectory})
if (gitBranch !== 'master') {
console.log('❌ Error: Refusing to deploy non-master branch.\n')
process.exit(1)
}
} }
// //
...@@ -237,7 +251,6 @@ async function buildBinary () { ...@@ -237,7 +251,6 @@ async function buildBinary () {
// //
// Build. // Build.
// //
const mainSourceDirectory = path.join(__dirname, '..')
// Move all the third-party binaries out of the node_modules folders so they // Move all the third-party binaries out of the node_modules folders so they
// are not all included in the various builds. // are not all included in the various builds.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment