File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Deploy to ECS
2+ description : Build Docker image, push to ECR, and deploy to ECS
3+
4+ inputs :
5+ aws-iam :
6+ description : Ending part of the ARN of the IAM role to assume for AWS credentials
7+ required : true
8+ cluster :
9+ description : Name of the ECS cluster to deploy to
10+ required : true
11+
12+ runs :
13+ using : composite
14+ steps :
15+ - name : Configure AWS credentials
16+ uses : aws-actions/configure-aws-credentials@v6
17+ with :
18+ role-to-assume : arn:aws:iam::${{ inputs.aws-iam }}
19+ aws-region : us-east-1
20+
21+ - name : Login to Amazon ECR
22+ id : login-ecr
23+ uses : aws-actions/amazon-ecr-login@v2
24+
25+ - name : Set up Docker Buildx
26+ uses : docker/setup-buildx-action@v3
27+
28+ - name : Build and tag the Docker image
29+ env :
30+ REGISTRY : ${{ steps.login-ecr.outputs.registry }}
31+ uses : docker/build-push-action@v6
32+ with :
33+ context : .
34+ tags : ${{ env.REGISTRY }}/docs-rs-web:latest
35+ target : web-server
36+ file : dockerfiles/Dockerfile
37+ push : true
38+ cache-from : type=gha
39+ cache-to : type=gha,mode=max
40+ build-args : GIT_VERSION=${{ github.sha }}
41+
42+ - name : Kick ECS to deploy new version
43+ shell : bash
44+ env :
45+ CLUSTER : ${{ inputs.cluster }}
46+ SERVICE : docs-rs-web
47+ run : |
48+ aws ecs update-service --service ${SERVICE} --cluster ${CLUSTER} --force-new-deployment
49+ # Poll every 15 seconds until a successful state has been reached. Fail after 40 failed checks.
50+ aws ecs wait services-stable --services ${SERVICE} --cluster ${CLUSTER}
Original file line number Diff line number Diff line change 99 docker :
1010 name : Build and upload docker image
1111 runs-on : ubuntu-latest
12+ environment : staging
13+ concurrency : staging
14+ if : github.repository_owner == 'rust-lang'
15+ permissions :
16+ id-token : write
17+ contents : read
1218 steps :
13- - uses : actions/checkout@v6
14-
15- - name : Build the Docker image
16- run : docker build -t docs-rs-web -f dockerfiles/Dockerfile --target web-server .
19+ - name : Checkout repository
20+ uses : actions/checkout@v6
21+ with :
22+ persist-credentials : false
1723
18- - name : Upload the Docker image to ECR (dev)
19- uses : rust-lang/simpleinfra/ github- actions/upload-docker-image@master
24+ - name : Deploy to ECS
25+ uses : ./. github/ actions/deploy-ecs
2026 with :
21- image : docs-rs-web
22- repository : docs-rs-web
23- region : us-east-1
24- aws_access_key_id : " ${{ secrets.staging_aws_access_key_id }}"
25- aws_secret_access_key : " ${{ secrets.staging_aws_secret_access_key }}"
26- redeploy_ecs_cluster : docs-rs-staging
27- redeploy_ecs_service : docs-rs-web
27+ aws-iam : " 519825364412:role/ci--rust-lang--docs.rs--staging"
28+ cluster : docs-rs-staging
Original file line number Diff line number Diff line change 88 prod :
99 name : Production
1010 runs-on : ubuntu-latest
11+ environment : production
12+ concurrency : production
13+ permissions :
14+ id-token : write
15+ contents : read
1116 steps :
12- - uses : actions/checkout@v6
13-
14- - name : Build the Docker image
15- run : docker build -t docs-rs-web -f dockerfiles/Dockerfile --target web-server .
17+ - name : Checkout repository
18+ uses : actions/checkout@v6
19+ with :
20+ persist-credentials : false
1621
17- - name : Upload the Docker image to ECR (production)
18- uses : rust-lang/simpleinfra/ github- actions/upload-docker-image@master
22+ - name : Deploy to ECS
23+ uses : ./. github/ actions/deploy-ecs
1924 with :
20- image : docs-rs-web
21- repository : docs-rs-web
22- region : us-west-1
23- aws_access_key_id : " ${{ secrets.aws_access_key_id }}"
24- aws_secret_access_key : " ${{ secrets.aws_secret_access_key }}"
25- redeploy_ecs_cluster : rust-ecs-prod
26- redeploy_ecs_service : docs-rs-web
25+ aws-iam : " 760062276060:role/ci--rust-lang--docs.rs--production"
26+ cluster : docs-rs-prod
You can’t perform that action at this time.
0 commit comments