Skip to content

Instantly share code, notes, and snippets.

@balupton
Last active January 22, 2016 16:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save balupton/a10abaf708c835eed154 to your computer and use it in GitHub Desktop.
Save balupton/a10abaf708c835eed154 to your computer and use it in GitHub Desktop.
DocPad Continuous Deployment
# 2016 January 23
# https://docpad.org/docs/deploy
# We use node
machine:
node:
version: "4"
dependencies:
cache_directories:
- "node_modules"
# Deployment
machine:
pre:
- git config --global user.email "$DEPLOY_NAME"
- git config --global user.name "$DEPLOY_EMAIL"
deployment:
production:
commands:
- >
if ([ "$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME" == "$DEPLOY_OWNER/$DEPLOY_REPO" ] &&
[ "$CIRCLE_BRANCH" == "$DEPLOY_BRANCH" ] &&
[ -z "$CI_PULL_REQUEST" ]); then
echo "Deploying...";
npm run-script deploy;
echo "Deloyed";
else
echo "Skipped deploy";
fi
# Custom Configuration
machine:
environment:
DEPLOY_OWNER: "docpad" # this is the repository owner's username that you want tested and deployed, set correctly
DEPLOY_REPO: "website" # this is the repository name that you want tested and deployed, set correctly
DEPLOY_BRANCH: "master" # this is the branch name that you want tested and deployed, set correctly
DEPLOY_NAME: "Travis CI Deployer" # this is the name that is used for the deployment commit, set to whatever
DEPLOY_EMAIL: "deployer@travis-ci.org" # this is the email that is used for the deployment commit, set to whatever you like
# 2016 January 23
# https://docpad.org/docs/deploy
# Use the latest travis infrastructure
sudo: false
# We use node
language: node_js
node_js:
- 4
cache:
directories:
- node_modules
# Prepare and run our tests
script: "npm test"
# Deployment
after_success: >
if ([ ! -z "$DEPLOY_TOKEN" ] &&
[ "$TRAVIS_BRANCH" == "$DEPLOY_BRANCH" ] &&
[ -z "$TRAVIS_TAG" ] &&
[ "$TRAVIS_PULL_REQUEST" == "false" ]); then
echo "Deploying";
git config --global user.email "$DEPLOY_EMAIL";
git config --global user.name "$DEPLOY_NAME";
git remote rm origin;
git remote add origin "https://$DEPLOY_USER:$DEPLOY_TOKEN@github.com/$TRAVIS_REPO_SLUG.git";
npm run-script deploy;
echo "Deployed";
else
echo "Skipped deploy"
fi
# Custom Configuration
# travis encrypt --org "DEPLOY_USER=$GITHUB_USERNAME" --add env.global
# travis encrypt --org "DEPLOY_TOKEN=$GITHUB_TRAVIS_TOKEN" --add env.global
env:
global:
- DEPLOY_BRANCH="master" # this is the branch name that you want tested and deployed, set correctly
- DEPLOY_NAME="Travis CI Deployer" # this is the name that is used for the deployment commit, set to whatever
- DEPLOY_EMAIL="deployer@travis-ci.org" # this is the email that is used for the deployment commit, set to whatever
# 2016 January 23
# https://docpad.org/docs/deploy
# Use the latest travis infrastructure
sudo: false
# We use node
language: ruby
rvm:
- "2.2"
# Deployment
# This should be easier, but https://github.com/travis-ci/travis.rb/issues/315 is a thing
# Doesn't use --debug on `travis login` as that will output our github token
install: gem install travis --no-rdoc --no-ri
script: >
if [ ! -z $GITHUB_TRAVIS_TOKEN ]; then
echo "Deploying...";
travis login --skip-completion-check --org --github-token "$GITHUB_TRAVIS_TOKEN";
export TRAVIS_ACCESS_TOKEN=`cat ~/.travis/config.yml | grep access_token | sed 's/ *access_token: *//'`;
travis restart --debug --skip-completion-check --org -r "$DEPLOY_REPO_SLUG" -t "$TRAVIS_ACCESS_TOKEN";
echo "Deployed";
else
echo "Skipped deploy";
fi
# Custom Configuration
# travis encrypt --org "GITHUB_TRAVIS_TOKEN=$GITHUB_TRAVIS_TOKEN" --add env.global
env:
global:
- DEPLOY_REPO_SLUG="docpad/website" # this is the repo owner and repo name that you want tested and deployed, set correctly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment