-
-
Save groony/4dd88112960d428a19c78a114a22ba59 to your computer and use it in GitHub Desktop.
capistrano deployment using CircleCI 2.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 2 | |
jobs: | |
build: | |
docker: | |
- image: ruby:2.3.3-alpine | |
working_directory: /home/circleci/masutaka.net | |
steps: | |
- setup_remote_docker: | |
# https://circleci.com/docs/2.0/docker-layer-caching/ | |
reusable: true | |
- run: | |
name: Install System Dependencies | |
# See also https://circleci.com/docs/2.0/custom-images/#required-tools | |
command: apk add --update --no-cache git openssh-client tar gzip build-base tzdata | |
- run: | |
name: Set timezone to Asia/Tokyo | |
command: cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime | |
- checkout | |
- restore_cache: | |
name: Restore bundler cache | |
keys: | |
- gems-{{ .Environment.COMMON_CACHE_KEY }}-{{ checksum "Gemfile.lock" }} | |
- gems-{{ .Environment.COMMON_CACHE_KEY }}- | |
- run: | |
name: Install Ruby Dependencies | |
command: bundle check || bundle install --jobs=4 --retry=3 | |
- save_cache: | |
name: Save bundler cache | |
key: gems-{{ .Environment.COMMON_CACHE_KEY }}-{{ checksum "Gemfile.lock" }} | |
paths: | |
- /usr/local/bundle | |
- add_ssh_keys: | |
fingerprints: | |
# for ssh to masutaka.net | |
# See https://circleci.com/gh/masutaka/masutaka.net/edit#ssh | |
- "43:7f:b2:..." | |
- deploy: | |
name: Maybe Deploy | |
command: | | |
if [ "${CIRCLE_BRANCH}" != "master" ]; then | |
exit 0 | |
fi | |
if [ -z "${BUNDLE_UPDATE}" ]; then | |
./script/deploy-circleci.sh | |
else | |
gem install -N bundler circleci-bundle-update-pr | |
circleci-bundle-update-pr CircleCI [email protected] | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -eu | |
cat <<EOF >> $HOME/.ssh/config | |
User masutaka | |
ForwardAgent yes | |
EOF | |
# Add the preferred key for getting GitHub Permission | |
# See https://circleci.com/gh/masutaka/masutaka.net/edit#checkout | |
eval $(ssh-agent) | |
ssh-add | |
bundle exec cap prod deploy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment