Skip to content

Instantly share code, notes, and snippets.

@Quar
Last active December 7, 2017 19:10
Show Gist options
  • Select an option

  • Save Quar/00f23e0e3f1d88062145d58b10cb177d to your computer and use it in GitHub Desktop.

Select an option

Save Quar/00f23e0e3f1d88062145d58b10cb177d to your computer and use it in GitHub Desktop.
Simplify `travis encrypt ... --add` on macOS, use KeyChain

travis-allow-push

Simplify travis encrypt ... --add on macOS, use KeyChain

Install

  1. Get Github Access Token follow the link.

  2. Add link to KeyChain with:

    Name: GITHUB_TOKEN Kind: application password Account: <your_user_name> password: <your_github_access_token>

  3. Copy this script to folder in $PATH

Usage:

Get help:

travis-allow-push --help

Allow travis to push for current GitHub repo:

# cd <your_repo>
travis-allow-push

Caveats:

To be prudent, it is NOT recommended to "always allow" security to access this entry in KeyChain, which means you will have to type your macOS login password everytime you want to allow travis push on a repo.

By default, you will have to type macOS login password TWICE everytime, and you can change this behavior to type login password ONCE everytime after adding application /usr/bin/security to the entrie's Access Control:

ref: apple.stackexchange.com 164545

  1. Double-click the keychain entry "GITHUB_TOKEN"
  2. Swith to right tab named "Access Control"
  3. Click "+" under "Always allow access by these applications"
  4. Press "Command + Shift + g", and type "/usr/bin/security", press "enter"
  5. Type macOS login password, and done.

ToDo:

Execute this script multiple times results in adding encryptions of the same info multiple times, which is redudant but not harmful.

#!/bin/bash
# allow travis to push back to github repo (e.g. gh-pages)
function get_help {
cat <<"EOF"
travis-allow-push
===========
Simplify `travis encrypt ... --add` on macOS, use KeyChain
#### Install
0. Get Github Access Token follow the [link](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/).
1. Add link to KeyChain with:
Name: GITHUB_TOKEN
Kind: application password
Account: <your_user_name>
password: <your_github_access_token>
2. Copy this script to folder in `$PATH`
#### Usage:
Get help:
``` bash
travis-allow-push --help
```
Allow travis to push for current GitHub repo:
``` bash
# cd <your_repo>
travis-allow-push
```
#### Caveats:
To be prudent, it is NOT recommended to "always allow" security to
access this entry in KeyChain, which means you will have to type your macOS
login password everytime you want to allow travis push on a repo.
By default, you will have to type macOS login password *TWICE everytime*, and
you can change this behavior to type login password *ONCE everytime* after
adding application `/usr/bin/security` to the entrie's Access Control:
> ref: apple.stackexchange.com 164545
1. Double-click the keychain entry "GITHUB_TOKEN"
2. Swith to right tab named "Access Control"
3. Click "+" under "Always allow access by these applications"
4. Press "Command + Shift + g", and type "/usr/bin/security", press "enter"
5. Type macOS login password, and done.
#### ToDo:
Execute this script multiple times results in adding encryptions of the same
info multiple times, which is redudant but not harmful.
EOF
}
if [ $# -gt 0 ]; then
get_help
exit 0
fi
travis encrypt GITHUB_TOKEN=$(security find-generic-password -l GITHUB_TOKEN -w) --add env.global
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment