问题
I have a Personal Access Token from Github that I use in many of my projects. Since the token has read/write ability for all my repos, it's important I use the Travis Command Line Tool to encrypt the GITHUB_TOKEN
and place it in my .travis.yml
as a secure variable:
travis encrypt GITHUB_TOKEN=****secret**** --add
The Problem
- The
GITHUB_TOKEN
value is a hard to remember string of random characters, so every time I need it I first have to go find it, and then copy n' paste it into git bash. - Whenever I use the
travis encrypt
method, it associates theGITHUB_TOKEN
with ONLY the repository I'm in.
Question
Is it possible to make this travis command an alias I can use over and over?
[alias]
git repo-encrypt = "travis encrypt GITHUB_TOKEN=****secret**** --add"
If so, how and where?
回答1:
The simple way to add the alias would be to run this one-liner:
git config --global alias.repo-encrypt '!travis encrypt GITHUB_TOKEN=****secret**** --add'
Alternatively, you can run git config --global --edit
to open the global Git configuration in your configured text editor (controlled by the core.editor config value of Git). Then add the following to the file:
[alias]
repo-encrypt = "!travis encrypt GITHUB_TOKEN=****secret**** --add"
After you add the alias, running git repo-encrypt
will execute the Travis command. For future reference, starting a Git alias with a !
makes it execute the command as though it were a normal shell, instead of simply appending the alias onto the end of the git
command as it would normally.
See the Git SCM Book page on aliases for more information.
来源:https://stackoverflow.com/questions/41133801/can-i-make-alias-for-travis-yaml-configuration-command-travis-encrypt-gith