diff --git a/gulpfile.js b/gulpfile.js index c02d71840..a7e26ee47 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -56,6 +56,7 @@ module.exports = { gitSyncMaster: gitTasks.syncMaster, gitCreateRC: gitTasks.createRC, gitRecompile: gitTasks.recompile, + gitUpdateGithubPages: gitTasks.updateGithubPages, typings: typings.typings, package: packageTasks.package, checkLicenses: licenseTasks.checkLicenses diff --git a/package.json b/package.json index b55186cf8..42858ffb2 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "test:setupselenium": "selenium-standalone install --config=./tests/scripts/selenium-config.js", "test:startselenium": "selenium-standalone start --config=./tests/scripts/selenium-config.js", "typings": "gulp typings", + "updateGithubPages": "gulp gitUpdateGithubPages", "version": "gulp build && git add -A" }, "main": "./index.js", diff --git a/scripts/gulpfiles/git_tasks.js b/scripts/gulpfiles/git_tasks.js index a0262cebc..63cbef780 100644 --- a/scripts/gulpfiles/git_tasks.js +++ b/scripts/gulpfiles/git_tasks.js @@ -21,7 +21,7 @@ const upstream_url = "https://github.com/google/blockly.git"; function syncBranch(branchName) { return function(done) { execSync('git stash save -m "Stash for sync"', { stdio: 'inherit' }); - execSync('git checkout ' + branchName, { stdio: 'inherit' }); + checkoutBranch(branchName); execSync('git pull ' + upstream_url + ' ' + branchName, { stdio: 'inherit' }); execSync('git push origin ' + branchName, { stdio: 'inherit' }); @@ -56,6 +56,13 @@ function getRCBranchName() { return 'rc_' + yyyy + '_' + mm; }; +// If branch does not exist then create the branch. +// If branch exists switch to branch. +function checkoutBranch(branchName) { + execSync('git checkout ' + branchName + ' || git checkout -b ' + branchName, + { stdio: 'inherit' }); +} + // Recompile and push to origin. const recompile = gulp.series( syncDevelop, @@ -93,9 +100,20 @@ const createRC = gulp.series( }, ); +// Update github pages with what is currently in develop. +const updateGithubPages = gulp.series( + syncBranch('gh-pages'), + function(done) { + execSync('git pull ' + upstream_url + ' develop', { stdio: 'inherit' }); + execSync('git push ' + upstream_url + ' gh-pages', { stdio: 'inherit' }); + done(); + } +); + module.exports = { syncDevelop: syncDevelop, syncMaster: syncMaster, createRC: createRC, - recompile: recompile + recompile: recompile, + updateGithubPages: updateGithubPages }