Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/actions/deploy-ecs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Deploy to ECS
description: Build Docker image, push to ECR, and deploy to ECS

inputs:
aws-iam:
description: Ending part of the ARN of the IAM role to assume for AWS credentials
required: true
cluster:
description: Name of the ECS cluster to deploy to
required: true

runs:
using: composite
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: arn:aws:iam::${{ inputs.aws-iam }}
aws-region: us-east-1

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and tag the Docker image
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
uses: docker/build-push-action@v6
with:
context: .
tags: ${{ env.REGISTRY }}/docs-rs-web:latest
target: web-server
file: dockerfiles/Dockerfile
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: GIT_VERSION=${{ github.sha }}

- name: Kick ECS to deploy new version
shell: bash
env:
CLUSTER: ${{ inputs.cluster }}
SERVICE: docs-rs-web
run: |
aws ecs update-service --service ${SERVICE} --cluster ${CLUSTER} --force-new-deployment
# Poll every 15 seconds until a successful state has been reached. Fail after 40 failed checks.
aws ecs wait services-stable --services ${SERVICE} --cluster ${CLUSTER}
27 changes: 14 additions & 13 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@ jobs:
docker:
name: Build and upload docker image
runs-on: ubuntu-latest
environment: staging
concurrency: staging
if: github.repository_owner == 'rust-lang'
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v6

- name: Build the Docker image
run: docker build -t docs-rs-web -f dockerfiles/Dockerfile --target web-server .
- name: Checkout repository
uses: actions/checkout@v6
with:
persist-credentials: false

- name: Upload the Docker image to ECR (dev)
uses: rust-lang/simpleinfra/github-actions/upload-docker-image@master
- name: Deploy to ECS
uses: ./.github/actions/deploy-ecs
with:
image: docs-rs-web
repository: docs-rs-web
region: us-east-1
aws_access_key_id: "${{ secrets.staging_aws_access_key_id }}"
aws_secret_access_key: "${{ secrets.staging_aws_secret_access_key }}"
redeploy_ecs_cluster: docs-rs-staging
redeploy_ecs_service: docs-rs-web
aws-iam: "519825364412:role/ci--rust-lang--docs.rs--staging"
cluster: docs-rs-staging
26 changes: 13 additions & 13 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ jobs:
prod:
name: Production
runs-on: ubuntu-latest
environment: production
concurrency: production
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v6

- name: Build the Docker image
run: docker build -t docs-rs-web -f dockerfiles/Dockerfile --target web-server .
- name: Checkout repository
uses: actions/checkout@v6
with:
persist-credentials: false

- name: Upload the Docker image to ECR (production)
uses: rust-lang/simpleinfra/github-actions/upload-docker-image@master
- name: Deploy to ECS
uses: ./.github/actions/deploy-ecs
with:
image: docs-rs-web
repository: docs-rs-web
region: us-west-1
Comment thread
marcoieni marked this conversation as resolved.
aws_access_key_id: "${{ secrets.aws_access_key_id }}"
aws_secret_access_key: "${{ secrets.aws_secret_access_key }}"
redeploy_ecs_cluster: rust-ecs-prod
redeploy_ecs_service: docs-rs-web
aws-iam: "760062276060:role/ci--rust-lang--docs.rs--production"
cluster: docs-rs-prod
Loading