This guide contains instructions on how to:
- Create GitHub Repository
- Create Golang App
- Create Dockerfile for Golang
- Create GitHub Actions Workflow
- Create AWS ECR Repository
- Create AWS IAM User, Policy, and Group
- Test GitHub Actions
- Add Automatic Tagging of Releases
- Create GitHub repo
lesson-086
- Clone repository
git clone [email protected]:antonputra/lesson-086.git
- Initialize the Go module
go mod init github.com/antonputra/lesson-086
-
Create
main.go
file -
Format the code and run it
# go install golang.org/x/tools/cmd/goimports@latest
go mod tidy
goimports -w .
go run main.go
- Create
Dockerfile
- Create
.github/workflows/main.yml
file, uselatest
forIMAGE_TAG
- Go to AWS console, search for
ecr
- Create private ECR repository
lesson-086
- Create IAM Policy
AllowPushPullPolicy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "GetAuthorizationToken",
"Effect": "Allow",
"Action": [
"ecr:GetAuthorizationToken"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"ecr:BatchGetImage",
"ecr:BatchCheckLayerAvailability",
"ecr:CompleteLayerUpload",
"ecr:GetDownloadUrlForLayer",
"ecr:InitiateLayerUpload",
"ecr:PutImage",
"ecr:UploadLayerPart"
],
"Resource": [
"arn:aws:ecr:us-east-1:424432388155:repository/lesson-086"
]
}
]
}
-
Create
push-pull-images
IAM Group and attachAllowPushPullPolicy
IAM Policy -
Create user
github-actions
and place it topush-pull-images
IAM Group
- Create initial commit
git add .
git commit -m 'init commit'
git push origin main
- Check ECR repository
-
Create
build/git_update.sh
script -
Make a change and push to remote branch from
main
-
Create a new branch
aputra
, make a change, updatepatch
->major
and push
- Delete
github-actions
AWS IAM User - Delete
AllowPushPullPolicy
AWS IAM Policy - Delete
push-pull-images
AWS IAM Group