Skip to content

Commit 175746c

Browse files
authored
Update Readme.md
1 parent e15643f commit 175746c

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

Readme.md

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,59 +10,67 @@ Use the following steps to prepare your workflow for running on your EC2 self-ho
1010
1. Create IAM user with AWS access keys
1111
Create an IAM user with the required EC2 roles. To create, go to IAM -> Create user.
1212
![image](https://github.com/shivaniii23/python-multi-stage-github-actions/assets/54891990/3648fa0f-b0e3-45f8-bafd-3c468bead418)
13+
![image](https://github.com/shivaniii23/python-multi-stage-github-actions/assets/54891990/ce77e45d-00ac-419b-b964-fdd3fd48d30d)
1314

1415
Then click on next -> create.
1516
Then we need to create the access key for this user. Click on the user -> Create access key .
16-
17+
![image](https://github.com/shivaniii23/python-multi-stage-github-actions/assets/54891990/d9fea834-d608-49d5-86ae-c29736d1081d)
18+
![image](https://github.com/shivaniii23/python-multi-stage-github-actions/assets/54891990/52e438df-60d4-4092-a9f8-7cde59f3a225)
1719

1820
Click on next -> create access key.
19-
21+
![image](https://github.com/shivaniii23/python-multi-stage-github-actions/assets/54891990/e0b79758-b697-4027-b60f-f6420109f4bf)
22+
2023
Download the .csv file which will have the access key and the secret key.
2124
Now, we will add these keys in our GitHub repository that we will use for this project.
2225
Go to your repository on GitHub -> settings -> Secrets and variables -> Actions -> Secrets -> Repository secrets.
26+
![image](https://github.com/shivaniii23/python-multi-stage-github-actions/assets/54891990/a4a828cd-d922-49b3-84ca-a988fab50210)
2327

24-
2528
Add the secret key and access key from the csv we downloaded and the AWS_REGION.(eg - us-east-1).
2629

2730
2. Prepare GitHub personal access token
2831
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.
2932
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.
3033
You will get the token. Copy it because it won’t be accessible afterwards.
31-
34+
![image](https://github.com/shivaniii23/python-multi-stage-github-actions/assets/54891990/54409118-bba1-457b-8e4e-cafadef5d364)
35+
3236
Now, we will add this token in our GitHub repository that we will use for this project.
3337
We will also add docker hub credentials so that we can push the docker image.
3438
Go to your repository on GitHub -> settings -> Secrets and variables -> Actions -> Secrets -> Repository secrets.
35-
39+
![image](https://github.com/shivaniii23/python-multi-stage-github-actions/assets/54891990/07dc9da9-6b67-4fdd-bff3-16366886c946)
3640

3741
3. Prepare EC2 image
3842
Create a new EC2 instance based on any Linux distribution you need. Select a key-pair and new security group and create the instance.
3943
Connect to the instance using SSH, install docker, then enable docker service –
40-
sudo apt-get update
41-
sudo apt install docker.io -y
42-
sudo systemctl enable --now docker
43-
sudo usermod -aG docker $USER && newgrp docker
44-
sudo systemctl restart docker
44+
sudo apt-get update
45+
sudo apt install docker.io -y
46+
sudo systemctl enable --now docker
47+
sudo usermod -aG docker $USER && newgrp docker
48+
sudo systemctl restart docker
4549
Install any other tools required for your workflow. Create a new EC2 image (AMI) from the instance.
46-
50+
![image](https://github.com/shivaniii23/python-multi-stage-github-actions/assets/54891990/6b85f037-6e86-488b-a5c4-6c2bdb4157e2)
51+
4752
Select the instance -> Actions -> Image and templates -> Create image -> Enter the name and click on Create Image.
48-
53+
![image](https://github.com/shivaniii23/python-multi-stage-github-actions/assets/54891990/45282270-3689-4f9b-a5d3-7b4c20ca9884)
54+
4955
Check the status of the image and make sure it is in ‘available’ state. Remove the instance if not required anymore.
50-
56+
![image](https://github.com/shivaniii23/python-multi-stage-github-actions/assets/54891990/645a1464-3aae-4376-aa9d-41d384353e6b)
5157

5258
4. Prepare VPC with subnet and security group
5359
Create a new VPC and a new subnet in it. Or use the existing VPC and subnet. We will use the default VPC.
60+
![image](https://github.com/shivaniii23/python-multi-stage-github-actions/assets/54891990/ad892420-307b-4e30-89be-69da11766b01)
5461

5562
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.
56-
57-
63+
![image](https://github.com/shivaniii23/python-multi-stage-github-actions/assets/54891990/227da693-d12b-4102-b7f9-5c6bf31ca297)
64+
![image](https://github.com/shivaniii23/python-multi-stage-github-actions/assets/54891990/2b7127ac-3260-4846-a7b2-0fd646304c69)
5865

5966
5. Configure the GitHub workflow
6067
Create a new GitHub Actions workflow or edit the existing one. We have a project which creates a docker container with multi stage builds.
6168
Github repository - https://github.com/shivaniii23/python-multi-stage-github-actions.git
6269
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.
6370
Make sure you don’t have a repository on the hub with the same name as this one.
64-
65-
66-
67-
71+
![image](https://github.com/shivaniii23/python-multi-stage-github-actions/assets/54891990/38b7da6f-2322-42ff-a571-38913c0e79b4)
72+
![image](https://github.com/shivaniii23/python-multi-stage-github-actions/assets/54891990/0bf275b5-33e4-4829-a3c5-6189d157bd0e)
73+
![image](https://github.com/shivaniii23/python-multi-stage-github-actions/assets/54891990/f4b9ab4b-7ec3-4f7e-8095-4f17a2f6bd1d)
74+
![image](https://github.com/shivaniii23/python-multi-stage-github-actions/assets/54891990/b51d280f-e849-4e0a-b4ff-41bb1e0780cb)
75+
6876
Here, we can see that the docker image was built and pushed to docker hub.

0 commit comments

Comments
 (0)