Narrator: In the last section we installed Travis
inside of a temporary container.
We're now ready to log in to the Travis CLI,
so that it knows essentially who we are.
Right now inside the container,
when we run Travis,
we're just a random person.
And it doesn't note to associate any
files or settings,
that we're going to load into Travis CLI
with our personal Travis account.
So to log in to Travis,
we'll execute Travis login, like so.
Now when we run that command,
it's going to prompt us for our GitHub login information.
As a reminder, when we initially signed up to Travis CI,
we did not actually create a Travis account per se.
We signed in using our GitHub accounts.
So we need to make sure that we enter our,
GitHub login information, here.
So I'm going to enter in my GitHub username.
And then I'm going to put in my password as well.
Now on GitHub, I have two-factor authentication setup,
which means that I'm going to be texted a code to enter here
to my phone.
So I'm going to very quickly enter that.
And there we go.
I'm now successfully logged into Travis CI.
Alright, so now that we are successfully logged in,
we need to make sure that we copy the JSON file
that we downloaded from the Google Cloud Dashboard
just a little bit ago,
over into our volumed directory.
Which for us is the Complex Project folder.
So we're going to copy that folder over,
so that we can access that file inside of our container.
Okay, so inside of my Downloads directory,
I've got my folder Explorer open.
Here's that JSON file,
that I downloaded just a little bit ago.
And then I've got a second window here,
inside the complex directory.
This is the project folder that we're working out of,
and it's also a folder that is essentially volumed
or set up as a volume inside the container.
So I'm going to drag this file over, like so.
So that file now exists inside the complex directory.
And then at the same time,
I'm also going to rename that file,
just to make it a little bit easier to work with.
So I'm going to rename the file to,
service-account
.json.
Like so.
So now if I go back over to my terminal,
and I do an ls,
I should see service-account.json, right here.
Remember, you're only going to see this,
if you change into the /App folder.
So, if I print out my current working directory,
I'm inside of the App folder inside of the container.
So make sure you're inside of App, and once you are,
you should see that service-account.json file, up here.
Alright.
So now that we've got that file inside of here,
last thing we need to do is run travis encrypt-file,
and we're gonna specify the file that we want to encrypt.
And there's one little addition to this command.
We also need to specify the repository
that we want to tie the encrypted file to.
So it's going to look a little bit like this right here.
There we go.
So we'll do travis encrypt-file service-account.json,
and then we're gonna add on -r,
and then specify the exact name of the repository
that we want to tie this encrypted file to.
You can get the name of the repository right here,
by going back to the Travis dashboard,
and then looking at that project that we just tied
to Travis CI.
So here's that project that I just created,
over on GitHub.
It's the same project we just tied to Travis CI.
And so I'll see the entire name of the repository,
right here.
So this is what we're going to enter into
the encrypt-file command.
Now the reason I'm showing you this in great detail
is that your GitHub username
is going to be case sensitive,
when you enter it into this Travis CI command.
So you'll notice I have capital S and capital G.
I need to make sure that I enter specifically capital S
and capital G,
when I run encrypt-file.
Okay, so let's get to it.
I'll do travis encrypt-file.
I want to encrypt the service-account.json file.
And then I'll enter in the repository,
that I want to tie this encrypted file to.
So I'll enter in my GitHub username.
Notice how, again,
I've got capitals here,
for my,
GitHub username.
If you don't have any capitals in your GitHub username,
then you don't need any capitals.
I'm just saying it has to be case sensitive.
And then I'll do a /, and the name of the repository
that I want to tie this encrypted file to.
In my case, I named the repository multi-k8s, like so.
Alright, so I'm going to run that command.
It's then going to encrypt the file,
and then I get a couple directions here.
The first direction says that,
"I need to add the following to my build script."
So in the before install stage, in my travis.yml file.
So I need to add this command right here,
to my travis.yml file.
This command is essentially going to take the encrypted file
and then use.
Excuse me.
Use the encrypted version of the file,
that is stored up on Travis CI servers,
and unencrypt it.
So I'm going to copy that entire command.
I'll then go over to my travis.yml file,
and then I'm going to add a new entry
inside of my before install section, here.
So I'll add in a dash at the very start,
and then I'll paste in that command like so.
Now, please triple check.
Make sure that the first part of the command says openssl,
and then the very last at the very end of this line,
should say -d, like so.
Okay.
Now I can also look at the rest of the directions here.
It says that I need to make sure that I add
service-account.json.enc to my Git repository.
If you list out your files and folders,
insider of this directory now,
you'll see that it has created a new file
inside of here called service-account.json.enc,
enc standing for encrypted.
So this is a encrypted file right here.
It is safe to add to our Git repository.
But the original file, the service-account.json file?
Not safe to add to my GitHub repository.
So I'm going to open up my folder Explorer again.
Inside of here, here's the Complex Project folder.
I see service-account.json,
and I see service-account.json encrypted.
I'm going to make a 100% triple sure,
that I take the original service-account.json file,
and I delete it.
So really important, make sure you delete that.
I'm even going to add a big note on here right now,
just in case you're skipping through this section
very quickly.
I'm going to say very clearly,
"Delete the original
service-
account.json
file."
Please do that.
I beg you.
If you upload this file,
someone will get into your Google Cloud account,
and probably nasty things are going to happen.
So please, please, please delete the original file.
So now if I do an ls after deleting the file,
I should only see the new version.
The enc right here.
Again, this is the encrypted version, this file.
It is a 100% safe to upload up to GitHub,
and expose to the public at large.
Okay, so that's it.
That's the entire process.
So I'm now going to exit out of this container,
by running exit.
And now inside of my complex directory,
because this was a volumed folder,
I should see just the service-account.json.enc folder.
File, excuse me.
Now again, make sure you delete that original file.
You have to delete it.
I apologize for harping on this,
but I know someone out there is going to forget to
delete the file.
So make sure you delete that thing.
So now the last thing I'm going to do,
is I'm going to commit this added file right here.
So I'll do a git add,
and a git commit -m,
I'll say "Added encrypted service-account file".
Like so.
Okay. So that's pretty much it.
So we've now encrypted that service-account file,
and we are ready to make use of it inside of our
travis.yml file,
at some point in the future.
So let's take a quick pause right here,
and we'll continue in the next section.