Skip to content
Draft
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
65 changes: 65 additions & 0 deletions .github/actions/deploy-ecs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Deploy to ECS
description: Build Docker image, push to ECR, and deploy to ECS

inputs:
aws-role-arn:
description: ARN of the AWS IAM role to assume
required: true
aws-region:
description: AWS region to deploy to
required: false
default: us-east-2
ecr-repository:
description: ECR repository name
required: false
default: bors
ecs-service:
description: ECS service name
required: false
default: bors
ecs-cluster:
description: ECS cluster name
required: false
default: bors
image-tag:
description: Docker image tag
required: false
default: latest

runs:
using: composite
steps:
- name: Checkout repo
uses: actions/checkout@v6

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v5
with:
role-to-assume: ${{ inputs.aws-role-arn }}
aws-region: ${{ inputs.aws-region }}

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

- uses: docker/setup-buildx-action@v3

- name: Build and tag the Docker image
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: ${{ inputs.ecr-repository }}
IMAGE_TAG: ${{ inputs.image-tag }}
uses: docker/build-push-action@v6
with:
context: .
tags: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Kick ECS to deploy new version
shell: bash
run: |
aws ecs update-service --service ${{ inputs.ecs-service }} --cluster ${{ inputs.ecs-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 ${{ inputs.ecs-service }} --cluster ${{ inputs.ecs-cluster }}
34 changes: 3 additions & 31 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,7 @@ jobs:
id-token: write
contents: read
steps:
- name: Checkout repo
uses: actions/checkout@v6

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v5
- name: Deploy to ECS
uses: ./.github/actions/deploy-ecs
with:
role-to-assume: arn:aws:iam::351621253146:role/gha-access
aws-region: us-east-2

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

- uses: docker/setup-buildx-action@v3
- name: Build and tag the Docker image
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: bors
IMAGE_TAG: latest
uses: docker/build-push-action@v6
with:
context: .
tags: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Kick ECS to deploy new version
run: |
aws ecs update-service --service bors --cluster bors --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 bors --cluster bors
aws-role-arn: arn:aws:iam::351621253146:role/gha-access
34 changes: 3 additions & 31 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,7 @@ jobs:
id-token: write
contents: read
steps:
- name: Checkout repo
uses: actions/checkout@v6

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v5
- name: Deploy to ECS
uses: ./.github/actions/deploy-ecs
with:
role-to-assume: arn:aws:iam::392478027976:role/gha-access
aws-region: us-east-2

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

- uses: docker/setup-buildx-action@v3
- name: Build and tag the Docker image
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: bors
IMAGE_TAG: latest
uses: docker/build-push-action@v6
with:
context: .
tags: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Kick ECS to deploy new version
run: |
aws ecs update-service --service bors --cluster bors --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 bors --cluster bors
aws-role-arn: arn:aws:iam::392478027976:role/gha-access