Auto build and upload to AWS new docker image after commit in repo
how can I automate this process? I have an script to push dockerimage to AWS through ecr.

You are on the right track. Yes, this should be an automated process from Git push or when someone merge a Pull Request.
An important aspect of this is that this &quot;automated process&quot; should be on a dedicated system - such that it is repeatable in a consistent way. Typically this is called a &quot;Continuous Integration Server&quot; or just &quot;Build Server&quot;.
Some popular choices for this kind of process:

Jenkins - old but popular
Tekton - Kubernetes native - but still in development
GitHub Actions - probably most interesting if your Git repo is on GitHub
Bitbucket Pipelines - probably most interesting if your Git repo is Bitbucket
AWS CodeBuild - limited but may be interesting if you use AWS
GitLab CI - probably most interesting if your Git repo is on GitLab

What you need to do is to configure your Git repository system (e.g. GitHub, Bitbucket, Gitlab or AWS CodeCommit) to initiate Pipelines on the Build system (a product of those listed above)