You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then we need to create the access key for this user. Click on the user -> Create access key .
28
16
@@ -35,14 +23,17 @@ Go to your repository on GitHub -> settings -> Secrets and variables -> Actions
35
23
36
24
37
25
Add the secret key and access key from the csv we downloaded and the AWS_REGION.(eg - us-east-1).
26
+
38
27
2. Prepare GitHub personal access token
39
28
Create a new GitHub personal access token with the repository scope. The action will use the token for self-hosted runners’ management in the GitHub account on the repository level. Add the token to GitHub secrets.
40
29
Go to your GitHub profile on GitHub -> settings -> Developer Settings -> Personal Access Tokens -> Tokens(classic) -> Generate new token -> Generate new token(classic) -> Add note, set expiration date -> Select all the boxes in scope and -> Generate token.
41
30
You will get the token. Copy it because it won’t be accessible afterwards.
42
31
43
32
Now, we will add this token in our GitHub repository that we will use for this project.
33
+
We will also add docker hub credentials so that we can push the docker image.
44
34
Go to your repository on GitHub -> settings -> Secrets and variables -> Actions -> Secrets -> Repository secrets.
45
35
36
+
46
37
3. Prepare EC2 image
47
38
Create a new EC2 instance based on any Linux distribution you need. Select a key-pair and new security group and create the instance.
48
39
Connect to the instance using SSH, install docker, then enable docker service –
@@ -57,20 +48,21 @@ Select the instance -> Actions -> Image and templates -> Create image -> Enter t
57
48
58
49
Check the status of the image and make sure it is in ‘available’ state. Remove the instance if not required anymore.
59
50
51
+
60
52
4. Prepare VPC with subnet and security group
61
53
Create a new VPC and a new subnet in it. Or use the existing VPC and subnet. We will use the default VPC.
62
54
63
-
Create a new security group for the runners in the VPC. Only the outbound traffic on port 443 should be allowed for pulling jobs from GitHub. And inbound traffic on port 22 is required.
55
+
Create a new security group for the runners in the VPC. Only the inbound traffic on port 22 is required. Keep the outbound traffic port as it is.
64
56
65
-
66
57
58
+
67
59
5. Configure the GitHub workflow
68
60
Create a new GitHub Actions workflow or edit the existing one. We have a project which creates a docker container with multi stage builds.
We have deploy.yml file which has the job named ‘My First GitHub Actions’ which starts the EC2 runner on push, executes the job, and terminates the runner after everything.
We have “deploy.yml” file which has the job named ‘My First GitHub Actions’ which starts the EC2 runner on push, executes the job, and terminates the runner after everything.
63
+
Make sure you don’t have a repository on the hub with the same name as this one.
71
64
72
65
73
-
74
-
75
-
76
-
66
+
67
+
68
+
Here, we can see that the docker image was built and pushed to docker hub.
0 commit comments