Create a gist now

Instantly share code, notes, and snippets.

@callmekohei /Travis_Github.md Secret
Last active Jul 11, 2017

What would you like to do?

Travis to Github

chart

    folder A
    ->  repository A
    ->  Travis
    ->  repository B

prepare

gem install travis

login

go to folder A

$ travis login

create ssh pair keys

$ ssh-keygen -f deploy_key

add public key to Github repository

$ cat deploy_key.pub

Github repository B : Setting -> Deploy keys

encrypt key

$ travis encrypt-file deploy_key

openssl aes-256-cbc -K $encrypted_b811b6a1fc44_key -iv $encrypted_b811b6a1fc44_iv -in deploy_key.enc -out deploy_key -d

.gitignore

!.travis.yml
!deploy_key.enc
deploy_key
deploy_key.pub

.travis.yaml ( sample )

after_success:
  # prepare
  - openssl aes-256-cbc -K $encrypted_b811b6a1fc44_key -iv $encrypted_b811b6a1fc44_iv -in deploy_key.enc -out ~/.ssh/id_rsa -d
  - chmod 600 ~/.ssh/id_rsa
  - echo -e "Host github.com"                >> ~/.ssh/config
  - echo -e "\n\tUser git"                   >> ~/.ssh/config
  - echo -e "\n\tStrictHostKeyChecking no"   >> ~/.ssh/config
  - echo -e "\n\tIdentityFile ~/.ssh/id_rsa" >> ~/.ssh/config
  - echo -e "\n\tIdentitiesOnly yes"         >> ~/.ssh/config
  - echo -e "\n\tForwardAgent yes"           >> ~/.ssh/config
  - git config --global user.email "callmekohei@gmail.com"
  - git config --global user.name "callmekohei"
  # git operations
  - cd ..
  - git clone git@github.com:callmekohei/deoplete-fsharp-bin.git
  - rm -rf ./deoplete-fsharp-bin/bin_deopletefs
  - cp -rf ./deopletefs/bin_deopletefs ./deoplete-fsharp-bin/
  - cd ./deoplete-fsharp-bin
  - git add --all
  - git commit -m "by Travis CI (JOB $TRAVIS_JOB_NUMBER)"
  - git push origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment