Skip to content

Get branch without using gift #183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ jobs:

- run: npm install
- run: npm prune
# see if package-lock.json file has changed
# if yes, this means it is out of date
- run: git status

# save each node_modules folder per package
- save_cache:
Expand Down Expand Up @@ -135,6 +138,7 @@ workflows:
# and branches starting with special prefix
- develop
- /docs-.*/
- get-branch
requires:
- docs-tests
- deploy-docs-production:
Expand Down
42 changes: 2 additions & 40 deletions cy_scripts/deploy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable no-console */

const path = require('path')
const gift = require('gift')
const chalk = require('chalk')
const Promise = require('bluebird')
const inquirer = require('inquirer')
Expand All @@ -13,24 +12,17 @@ const shouldDeploy = require('./should-deploy')
const R = require('ramda')
const la = require('lazy-ass')
const is = require('check-more-types')
const git = require('ggit')
const {
warnIfNotCI,
getDeployEnvironment,
checkBranchEnvFolder,
uploadToS3,
getBranch,
} = require('@cypress/deploy-bits')

const distDir = path.resolve('public')
const isValidEnvironment = is.oneOf(['production', 'staging'])

// initialize on existing repo
const repo = Promise.promisifyAll(gift(path.resolve('..')))

function getCurrentBranch () {
return git.branchName()
}

function cliOrAsk (property, ask, minimistOptions) {
// for now isolate the CLI/question logic
const askRemaining = questionsRemain({
Expand All @@ -44,27 +36,6 @@ function prompt (questions) {
return Promise.resolve(inquirer.prompt(questions))
}

function commitMessage (env, branch) {
const msg = `docs: deployed to ${env} [skip ci]`

console.log(
'\n',
'Committing and pushing to remote origin:',
'\n',
chalk.green(`(${branch})`),
chalk.cyan(msg)
)

// commit empty message that we deployed
return repo.commitAsync(msg, {
'allow-empty': true,
})
.then(function () {
// and push it to the origin with the current branch
return repo.remote_pushAsync('origin', branch)
})
}

function prompToScrape () {
return prompt({
type: 'list',
Expand Down Expand Up @@ -111,18 +82,9 @@ function deployEnvironmentBranch (env, branch) {
la(is.unemptyString(branch), 'missing branch to deploy', branch)
la(isValidEnvironment(env), 'invalid deploy environment', env)

const maybeCommit = () =>
commitMessage(env, branch)
.catch((err) => {
// ignore commit error - do we really need it?
console.error('could not make a doc commit')
console.error(err.message)
})

checkBranchEnvFolder(branch)(env)

uploadToS3(distDir, env)
.then(maybeCommit)
.then(() => scrapeDocs(env, branch))
.then(() => {
console.log(chalk.yellow('\n==============================\n'))
Expand All @@ -134,7 +96,7 @@ function deployEnvironmentBranch (env, branch) {
function doDeploy (env) {
la(isValidEnvironment(env), 'invalid deploy environment', env)
debug('getting current branch')
return getCurrentBranch()
return getBranch()
.then((branch) => {
console.log('deploying branch %s to environment %s',
chalk.green(branch), chalk.blue(env))
Expand Down
Loading