-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4ccb4f
commit 816708f
Showing
3 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Packages | ||
|
||
This folder contains GitHub Actions workflows that are used to update the application. | ||
|
||
See `.github/workflows/backend_update.yml` for an example of how these workflows are used. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: 'Action for running an ECS task in a GHA workflow' | ||
description: 'Action for running ECS task' | ||
author: 'Brian Caffey' | ||
inputs: | ||
BASE_ENV: | ||
required: true | ||
description: 'Base env name (e.g. dev)' | ||
APP_ENV: | ||
required: true | ||
description: 'App env name (e.g. alpha)' | ||
VERSION: | ||
required: true | ||
description: 'Application version git tag (e.g. v1.2.3)' | ||
ECR_REPO: | ||
required: true | ||
description: 'ECR repo to use' | ||
CONTAINER_NAME: | ||
required: true | ||
description: 'Name of the container to update' | ||
AWS_REGION: | ||
required: false | ||
description: 'AWS Region' | ||
default: 'us-east-1' | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
# Note: this assumes that your ECR repo lives in the same AWS account as your ECS cluster | ||
- name: Get current AWS Account | ||
id: get-aws-account | ||
shell: bash | ||
run: | | ||
AWS_ACCOUNT_ID=$(aws sts get-caller-identity | jq -r .Account) | ||
echo $AWS_ACCOUNT_ID | ||
echo "AWS_ACCOUNT_ID=$AWS_ACCOUNT_ID" >> $GITHUB_ENV | ||
- name: Download existing task definition | ||
id: download-task-definition | ||
shell: bash | ||
# CONTAINER_NAME | ||
run: | | ||
aws ecs describe-task-definition \ | ||
--task-definition ${{ inputs.CONTAINER_NAME }} \ | ||
| jq '.taskDefinition' > task-definition.json | ||
- name: Remove fields from task definition | ||
id: cleaned-task-def | ||
shell: bash | ||
run: | | ||
jq 'del(.compatibilities, .taskDefinitionArn, .requiresAttributes, .revision, .status, .registeredAt, .registeredBy)' task-definition.json > cleaned-task-definition.json | ||
- name: Render new task definition | ||
id: render-new-task-definition | ||
uses: aws-actions/amazon-ecs-render-task-definition@v1 | ||
with: | ||
task-definition: cleaned-task-definition.json | ||
container-name: ${{ inputs.CONTAINER_NAME }} # CONTAINER_NAME | ||
image: ${{ env.AWS_ACCOUNT_ID }}.dkr.ecr.${{ inputs.AWS_REGION}}.amazonaws.com/${{ inputs.ECR_REPO }}:${{ inputs.VERSION }} | ||
|
||
- name: Deploy new task definition | ||
id: deploy-new-task-definition | ||
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | ||
with: | ||
cluster: ${{ inputs.APP_ENV }}-cluster #CLUSTER_NAME | ||
task-definition: ${{ steps.render-new-task-definition.outputs.task-definition }} | ||
service: ${{ inputs.APP_ENV }}-${{ inputs.CONTAINER_NAME }} # SERVICE_NAME | ||
wait-for-service-stability: true |