WEBVTT

00:00.780 --> 00:02.250
Narrator: In the last section we installed Travis

00:02.250 --> 00:03.870
inside of a temporary container.

00:03.870 --> 00:06.390
We're now ready to log in to the Travis CLI,

00:06.390 --> 00:09.000
so that it knows essentially who we are.

00:09.000 --> 00:10.440
Right now inside the container,

00:10.440 --> 00:11.670
when we run Travis,

00:11.670 --> 00:13.140
we're just a random person.

00:13.140 --> 00:14.790
And it doesn't note to associate any

00:14.790 --> 00:15.780
files or settings,

00:15.780 --> 00:17.940
that we're going to load into Travis CLI

00:17.940 --> 00:20.370
with our personal Travis account.

00:20.370 --> 00:22.170
So to log in to Travis,

00:22.170 --> 00:24.843
we'll execute Travis login, like so.

00:27.000 --> 00:27.960
Now when we run that command,

00:27.960 --> 00:30.810
it's going to prompt us for our GitHub login information.

00:30.810 --> 00:33.562
As a reminder, when we initially signed up to Travis CI,

00:33.562 --> 00:36.690
we did not actually create a Travis account per se.

00:36.690 --> 00:39.180
We signed in using our GitHub accounts.

00:39.180 --> 00:40.830
So we need to make sure that we enter our,

00:40.830 --> 00:43.230
GitHub login information, here.

00:43.230 --> 00:46.110
So I'm going to enter in my GitHub username.

00:46.110 --> 00:48.633
And then I'm going to put in my password as well.

00:51.540 --> 00:54.570
Now on GitHub, I have two-factor authentication setup,

00:54.570 --> 00:57.510
which means that I'm going to be texted a code to enter here

00:57.510 --> 00:58.470
to my phone.

00:58.470 --> 01:00.470
So I'm going to very quickly enter that.

01:02.400 --> 01:03.300
And there we go.

01:03.300 --> 01:06.063
I'm now successfully logged into Travis CI.

01:07.020 --> 01:09.270
Alright, so now that we are successfully logged in,

01:09.270 --> 01:12.000
we need to make sure that we copy the JSON file

01:12.000 --> 01:14.580
that we downloaded from the Google Cloud Dashboard

01:14.580 --> 01:15.690
just a little bit ago,

01:15.690 --> 01:17.880
over into our volumed directory.

01:17.880 --> 01:20.760
Which for us is the Complex Project folder.

01:20.760 --> 01:22.140
So we're going to copy that folder over,

01:22.140 --> 01:25.323
so that we can access that file inside of our container.

01:26.610 --> 01:28.440
Okay, so inside of my Downloads directory,

01:28.440 --> 01:30.270
I've got my folder Explorer open.

01:30.270 --> 01:31.560
Here's that JSON file,

01:31.560 --> 01:33.750
that I downloaded just a little bit ago.

01:33.750 --> 01:35.550
And then I've got a second window here,

01:35.550 --> 01:37.740
inside the complex directory.

01:37.740 --> 01:40.050
This is the project folder that we're working out of,

01:40.050 --> 01:42.960
and it's also a folder that is essentially volumed

01:42.960 --> 01:45.810
or set up as a volume inside the container.

01:45.810 --> 01:49.500
So I'm going to drag this file over, like so.

01:49.500 --> 01:52.590
So that file now exists inside the complex directory.

01:52.590 --> 01:53.760
And then at the same time,

01:53.760 --> 01:55.800
I'm also going to rename that file,

01:55.800 --> 01:58.470
just to make it a little bit easier to work with.

01:58.470 --> 02:00.750
So I'm going to rename the file to,

02:00.750 --> 02:03.187
service-account

02:03.187 --> 02:04.020
.json.

02:04.020 --> 02:04.853
Like so.

02:08.420 --> 02:10.410
So now if I go back over to my terminal,

02:10.410 --> 02:12.210
and I do an ls,

02:12.210 --> 02:16.050
I should see service-account.json, right here.

02:16.050 --> 02:17.910
Remember, you're only going to see this,

02:17.910 --> 02:21.150
if you change into the /App folder.

02:21.150 --> 02:23.190
So, if I print out my current working directory,

02:23.190 --> 02:25.980
I'm inside of the App folder inside of the container.

02:25.980 --> 02:28.380
So make sure you're inside of App, and once you are,

02:28.380 --> 02:31.293
you should see that service-account.json file, up here.

02:33.930 --> 02:34.763
Alright.

02:34.763 --> 02:36.240
So now that we've got that file inside of here,

02:36.240 --> 02:39.090
last thing we need to do is run travis encrypt-file,

02:39.090 --> 02:41.730
and we're gonna specify the file that we want to encrypt.

02:41.730 --> 02:43.808
And there's one little addition to this command.

02:43.808 --> 02:46.502
We also need to specify the repository

02:46.502 --> 02:49.173
that we want to tie the encrypted file to.

02:50.280 --> 02:53.610
So it's going to look a little bit like this right here.

02:53.610 --> 02:54.443
There we go.

02:55.380 --> 02:57.900
So we'll do travis encrypt-file service-account.json,

02:57.900 --> 02:59.760
and then we're gonna add on -r,

02:59.760 --> 03:02.670
and then specify the exact name of the repository

03:02.670 --> 03:05.100
that we want to tie this encrypted file to.

03:05.100 --> 03:07.680
You can get the name of the repository right here,

03:07.680 --> 03:09.909
by going back to the Travis dashboard,

03:09.909 --> 03:12.690
and then looking at that project that we just tied

03:12.690 --> 03:14.070
to Travis CI.

03:14.070 --> 03:15.960
So here's that project that I just created,

03:15.960 --> 03:16.860
over on GitHub.

03:16.860 --> 03:19.893
It's the same project we just tied to Travis CI.

03:19.893 --> 03:22.470
And so I'll see the entire name of the repository,

03:22.470 --> 03:23.303
right here.

03:23.303 --> 03:24.750
So this is what we're going to enter into

03:24.750 --> 03:26.087
the encrypt-file command.

03:26.087 --> 03:28.415
Now the reason I'm showing you this in great detail

03:28.415 --> 03:30.917
is that your GitHub username

03:30.917 --> 03:33.390
is going to be case sensitive,

03:33.390 --> 03:36.278
when you enter it into this Travis CI command.

03:36.278 --> 03:39.390
So you'll notice I have capital S and capital G.

03:39.390 --> 03:42.510
I need to make sure that I enter specifically capital S

03:42.510 --> 03:43.500
and capital G,

03:43.500 --> 03:45.033
when I run encrypt-file.

03:46.950 --> 03:48.540
Okay, so let's get to it.

03:48.540 --> 03:51.363
I'll do travis encrypt-file.

03:52.470 --> 03:56.430
I want to encrypt the service-account.json file.

03:56.430 --> 03:58.620
And then I'll enter in the repository,

03:58.620 --> 04:01.700
that I want to tie this encrypted file to.

04:01.700 --> 04:04.380
So I'll enter in my GitHub username.

04:04.380 --> 04:05.213
Notice how, again,

04:05.213 --> 04:07.080
I've got capitals here,

04:07.080 --> 04:08.640
for my,

04:08.640 --> 04:09.473
GitHub username.

04:09.473 --> 04:11.340
If you don't have any capitals in your GitHub username,

04:11.340 --> 04:12.840
then you don't need any capitals.

04:12.840 --> 04:15.074
I'm just saying it has to be case sensitive.

04:15.074 --> 04:18.630
And then I'll do a /, and the name of the repository

04:18.630 --> 04:21.000
that I want to tie this encrypted file to.

04:21.000 --> 04:24.573
In my case, I named the repository multi-k8s, like so.

04:26.820 --> 04:28.890
Alright, so I'm going to run that command.

04:28.890 --> 04:31.200
It's then going to encrypt the file,

04:31.200 --> 04:33.420
and then I get a couple directions here.

04:33.420 --> 04:34.507
The first direction says that,

04:34.507 --> 04:37.800
"I need to add the following to my build script."

04:37.800 --> 04:41.850
So in the before install stage, in my travis.yml file.

04:41.850 --> 04:44.640
So I need to add this command right here,

04:44.640 --> 04:46.410
to my travis.yml file.

04:46.410 --> 04:49.470
This command is essentially going to take the encrypted file

04:49.470 --> 04:50.340
and then use.

04:50.340 --> 04:51.173
Excuse me.

04:51.173 --> 04:52.620
Use the encrypted version of the file,

04:52.620 --> 04:54.930
that is stored up on Travis CI servers,

04:54.930 --> 04:56.550
and unencrypt it.

04:56.550 --> 04:58.600
So I'm going to copy that entire command.

04:59.580 --> 05:01.953
I'll then go over to my travis.yml file,

05:03.060 --> 05:04.920
and then I'm going to add a new entry

05:04.920 --> 05:08.280
inside of my before install section, here.

05:08.280 --> 05:10.320
So I'll add in a dash at the very start,

05:10.320 --> 05:13.320
and then I'll paste in that command like so.

05:13.320 --> 05:14.310
Now, please triple check.

05:14.310 --> 05:18.150
Make sure that the first part of the command says openssl,

05:18.150 --> 05:20.700
and then the very last at the very end of this line,

05:20.700 --> 05:22.863
should say -d, like so.

05:26.384 --> 05:27.217
Okay.

05:27.217 --> 05:29.040
Now I can also look at the rest of the directions here.

05:29.040 --> 05:31.260
It says that I need to make sure that I add

05:31.260 --> 05:35.250
service-account.json.enc to my Git repository.

05:35.250 --> 05:37.141
If you list out your files and folders,

05:37.141 --> 05:39.090
insider of this directory now,

05:39.090 --> 05:41.130
you'll see that it has created a new file

05:41.130 --> 05:44.220
inside of here called service-account.json.enc,

05:44.220 --> 05:46.200
enc standing for encrypted.

05:46.200 --> 05:48.240
So this is a encrypted file right here.

05:48.240 --> 05:51.090
It is safe to add to our Git repository.

05:51.090 --> 05:55.170
But the original file, the service-account.json file?

05:55.170 --> 05:58.500
Not safe to add to my GitHub repository.

05:58.500 --> 06:00.963
So I'm going to open up my folder Explorer again.

06:02.670 --> 06:05.182
Inside of here, here's the Complex Project folder.

06:05.182 --> 06:07.440
I see service-account.json,

06:07.440 --> 06:10.170
and I see service-account.json encrypted.

06:10.170 --> 06:13.680
I'm going to make a 100% triple sure,

06:13.680 --> 06:16.950
that I take the original service-account.json file,

06:16.950 --> 06:18.270
and I delete it.

06:18.270 --> 06:20.190
So really important, make sure you delete that.

06:20.190 --> 06:22.770
I'm even going to add a big note on here right now,

06:22.770 --> 06:24.942
just in case you're skipping through this section

06:24.942 --> 06:26.220
very quickly.

06:26.220 --> 06:27.757
I'm going to say very clearly,

06:27.757 --> 06:30.810
"Delete the original

06:30.810 --> 06:31.683
service-

06:32.700 --> 06:34.080
account.json

06:34.080 --> 06:35.010
file."

06:35.010 --> 06:35.843
Please do that.

06:35.843 --> 06:36.676
I beg you.

06:36.676 --> 06:37.590
If you upload this file,

06:37.590 --> 06:40.530
someone will get into your Google Cloud account,

06:40.530 --> 06:42.630
and probably nasty things are going to happen.

06:42.630 --> 06:45.783
So please, please, please delete the original file.

06:47.370 --> 06:49.740
So now if I do an ls after deleting the file,

06:49.740 --> 06:52.050
I should only see the new version.

06:52.050 --> 06:53.430
The enc right here.

06:53.430 --> 06:55.440
Again, this is the encrypted version, this file.

06:55.440 --> 06:57.990
It is a 100% safe to upload up to GitHub,

06:57.990 --> 07:00.243
and expose to the public at large.

07:01.140 --> 07:01.973
Okay, so that's it.

07:01.973 --> 07:03.180
That's the entire process.

07:03.180 --> 07:05.220
So I'm now going to exit out of this container,

07:05.220 --> 07:06.483
by running exit.

07:07.980 --> 07:09.780
And now inside of my complex directory,

07:09.780 --> 07:11.730
because this was a volumed folder,

07:11.730 --> 07:15.300
I should see just the service-account.json.enc folder.

07:15.300 --> 07:16.320
File, excuse me.

07:16.320 --> 07:18.480
Now again, make sure you delete that original file.

07:18.480 --> 07:19.470
You have to delete it.

07:19.470 --> 07:20.670
I apologize for harping on this,

07:20.670 --> 07:22.800
but I know someone out there is going to forget to

07:22.800 --> 07:23.633
delete the file.

07:23.633 --> 07:25.353
So make sure you delete that thing.

07:26.670 --> 07:27.990
So now the last thing I'm going to do,

07:27.990 --> 07:31.140
is I'm going to commit this added file right here.

07:31.140 --> 07:33.270
So I'll do a git add,

07:33.270 --> 07:35.730
and a git commit -m,

07:35.730 --> 07:40.650
I'll say "Added encrypted service-account file".

07:40.650 --> 07:41.483
Like so.

07:42.600 --> 07:43.770
Okay. So that's pretty much it.

07:43.770 --> 07:45.990
So we've now encrypted that service-account file,

07:45.990 --> 07:48.180
and we are ready to make use of it inside of our

07:48.180 --> 07:49.170
travis.yml file,

07:49.170 --> 07:50.850
at some point in the future.

07:50.850 --> 07:52.530
So let's take a quick pause right here,

07:52.530 --> 07:54.480
and we'll continue in the next section.
