Skip to content

Instantly share code, notes, and snippets.

@cfillion
Last active January 14, 2017 12:25
Show Gist options
  • Select an option

  • Save cfillion/2588d2f2755e8b6e5c5c03c4b723d1b8 to your computer and use it in GitHub Desktop.

Select an option

Save cfillion/2588d2f2755e8b6e5c5c03c4b723d1b8 to your computer and use it in GitHub Desktop.
Setting up travis to check and update index.xml using reapack-index

Instructions

  1. Generate a new ssh key without a passphrase:
    ssh-keygen -t rsa -b 4096 -f deploy_key -C 'travis index bot'
    
  2. Encrypt the generated key with a unique, secure passphrase:
gpg -c deploy_key
  1. Add the passphrase in an environment variable named DEPLOY_KEY_PASSPHRASE in travis repo settings
  2. Authorize deploy_key.pub to push to your repository on GitHub (Settings > Deploy Keys)
  3. Delete deploy_key and deploy_key.pub
  4. Commit deploy_key.gpg, deploy.sh (with the executable bit set and the correct repo URL) and .travis.yml

The concurrent build limit should probably be set to 1 on travis just to be safe.

language: ruby
rvm:
- 2.3.0
before_install:
- gem update bundler
- wget https://github.com/jgm/pandoc/releases/download/1.19.1/pandoc-1.19.1-1-amd64.deb -O pandoc.deb
- sudo dpkg -i pandoc.deb
- rm pandoc.deb
install: gem install reapack-index
script: reapack-index --check
deploy:
provider: script
script: ./deploy.sh
on:
branch: master
#!/bin/sh
set -e
cd "$(dirname "$0")"
echo $DEPLOY_KEY_PASSPHRASE | gpg --passphrase-fd 0 deploy_key.gpg
eval "$(ssh-agent -s)"
chmod 600 deploy_key
ssh-add deploy_key
git config push.default simple
git config user.name 'User Name'
git config user.email 'your@email.com'
git remote add deploy 'git@github.com:USER/REPO.git'
git fetch --unshallow || true
git checkout "$TRAVIS_BRANCH"
git pull
rvm $TRAVIS_RUBY_VERSION do reapack-index --commit
git push deploy "$TRAVIS_BRANCH"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment