{"id":16694036,"url":"https://github.com/haoliangyu/ecs-auto-deploy","last_synced_at":"2025-04-10T01:33:14.926Z","repository":{"id":144780194,"uuid":"124809761","full_name":"haoliangyu/ecs-auto-deploy","owner":"haoliangyu","description":"AWS ECS auto-deployment with Travis CI","archived":false,"fork":false,"pushed_at":"2018-04-22T20:35:33.000Z","size":20,"stargazers_count":15,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T03:11:30.530Z","etag":null,"topics":["auto-deployment","aws-ecs","continous-deployment","travis-ci"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/haoliangyu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-11T23:36:09.000Z","updated_at":"2023-09-05T21:39:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"8e3201b0-f1f0-4cae-913f-7d07c638bc54","html_url":"https://github.com/haoliangyu/ecs-auto-deploy","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haoliangyu%2Fecs-auto-deploy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haoliangyu%2Fecs-auto-deploy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haoliangyu%2Fecs-auto-deploy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haoliangyu%2Fecs-auto-deploy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haoliangyu","download_url":"https://codeload.github.com/haoliangyu/ecs-auto-deploy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248140638,"owners_count":21054325,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["auto-deployment","aws-ecs","continous-deployment","travis-ci"],"created_at":"2024-10-12T16:43:32.881Z","updated_at":"2025-04-10T01:33:14.894Z","avatar_url":"https://github.com/haoliangyu.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"# ecs-auto-deploy\n\n[![Build Status](https://travis-ci.org/haoliangyu/ecs-auto-deploy.svg?branch=master)](https://travis-ci.org/haoliangyu/ecs-auto-deploy)\n\nThis is an example project to show **how to use Travis CI for AWS ECS auto-deployment**.\n\n## how-to\n\nThis repository utilizes the [script deployment](https://docs.travis-ci.com/user/deployment/script/) of Travis CI and the [ecs-deploy](https://github.com/silinternational/ecs-deploy) library.\n\nIt establishes a continuous deployment pipeline to the [AWS ECS](https://aws.amazon.com/ecs/), which is triggered by every update on the `master` branch (like a PR).\n\n### Deployment Script\n\nA deployment script ([deploy.sh](./deploy.sh)) is used to build, push, and deploy the container image:\n\n* build the new docker image\n\n* push to an image repository with the `latest` tag\n\n* update the AWS ECS service with the new image.\n\n``` bash\n# install aws-sdk\npip install --user awscli\nexport PATH=$PATH:$HOME/.local/bin\n\n# install ecs-deploy\nadd-apt-repository ppa:eugenesan/ppa\napt-get update\napt-get install jq -y\n\ncurl https://raw.githubusercontent.com/silinternational/ecs-deploy/master/ecs-deploy | \\\n  sudo tee -a /usr/bin/ecs-deploy\nsudo chmod +x /usr/bin/ecs-deploy\n\n# Use this for AWS ECR\n# eval $(aws ecr get-login --region us-east-1)\n\n# Use this for Docker Hub\ndocker login --username $DOCKER_HUB_USER --password $DOCKER_HUB_PSW\n\n# Build and push the image to the repository\ndocker build -t haoliangyu/ecs-auto-deploy .\ndocker tag haoliangyu/ecs-auto-deploy:latest $IMAGE_REPO_URL:latest\ndocker push $IMAGE_REPO_URL:latest\n\n# deploy the new image to the aws ecs\necs-deploy -c $CLUSTER_NAME -n $SERVICE_NAME -i $IMAGE_REPO_URL:latest\n```\n\nThis script uses several environment variables to provide secrets:\n\n* `IMAGE_REPO_URL`: the url or name of container image repository\n* `CLUSTER_NAME`: AWS ECS cluster name\n* `SERVICE_NAME`: AWS ECS cluster service name\n\nTo login AWS, it reads the AWS credential either from the environment variables (`AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`) or the aws config file. If [Docker Hub](https://hub.docker.com) is used to host the image, the script uses the `DOCKER_HUB_USER` and `DOCKER_HUB_PSW` for `docker login`.\n\nA full example of needed environment variables is at [.env.example](./.env.example).\n\nNote that the [ecs-deploy](https://github.com/silinternational/ecs-deploy) library assumes that the target cluster and service are running and it is going to updat the task definition then deploy. If the service doesn't exist, the library will throw an error.\n\n### Travis CI Configuration\n\nThe following configuration ([.travis.yml](./.travis.yml)) is used to set up the deployment pipeline for every update on the `master` branch.\n\n``` yaml\n# We are using a nodejs application as an example\nlanguage: node_js\nnode_js:\n  - \"node\"\n\n# Install docker\nservices:\n  - docker\n\n# Use script deployment and specify the script path\ndeploy:\n  provider: script\n  script: bash deploy.sh\n  # Only deploy when the master branch is updated\n  on:\n    branch: master\n```\n\nTo enable it, you need to add all required environment variables to the Travis CI project setting.\n\n## blog post\n\nFor more details, please take a look at this blog post [AWS ECS continuous deployment with Travis CI](https://haoliangyu.github.io/blog/2018/03/19/AWS-ECS-auto-deployment-with-Travis-CI/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaoliangyu%2Fecs-auto-deploy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhaoliangyu%2Fecs-auto-deploy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaoliangyu%2Fecs-auto-deploy/lists"}