Skip to content

Commit

Permalink
add doc
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoparma88 committed May 14, 2024
1 parent 64137e5 commit f985ebc
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
push:
branches:
- main
- develop
- stage

jobs:
deploy:
Expand All @@ -18,17 +16,20 @@ jobs:
uses: actions/checkout@v4

- name: Configure AWS credentials
if: ${{ secrets.AWS_ACCESS_KEY_ID != '' }}
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ vars.AWS_REGION }}

- name: Login to Amazon ECR
if: ${{ secrets.AWS_ACCESS_KEY_ID != '' }}
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build, tag, and push image to Amazon ECR
if: ${{ secrets.AWS_ACCESS_KEY_ID != '' }}
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
Expand All @@ -40,10 +41,12 @@ jobs:
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Download task definition
if: ${{ secrets.AWS_ACCESS_KEY_ID != '' }}
run: |
aws ecs describe-task-definition --task-definition ${{ vars.ECS_TASK_DEFINITION }} --query taskDefinition > ${{ vars.ECS_TASK_DEFINITION_PATH }}
- name: Fill in the new image ID in the Amazon ECS task definition
if: ${{ secrets.AWS_ACCESS_KEY_ID != '' }}
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
Expand All @@ -52,6 +55,7 @@ jobs:
image: ${{ steps.build-image.outputs.image }}

- name: Deploy Amazon ECS task definition
if: ${{ secrets.AWS_ACCESS_KEY_ID != '' }}
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
Expand Down
31 changes: 31 additions & 0 deletions docs/cd_with_aws.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Continuous Deployment with AWS

This document explains how to set up Continuous Deployment (CD) with AWS using GitHub Actions.

## Prerequisites

Before you start, make sure you have the following:

1. **AWS Account**: You need an AWS account. Sign up [here](https://aws.amazon.com/).

2. **Amazon ECR (Elastic Container Registry) Setup**:
- Create a new repository in Amazon ECR.
- Note down the repository URI, which will be used in the GitHub Actions workflow.

3. **AWS Credentials**:
- AWS Access Key ID
- AWS Secret Access Key
- These credentials should have permissions to interact with ECR and ECS.

4. **GitHub Repository Setup**:
- Secrets: Add the following secrets to your GitHub repository:
- `AWS_ACCESS_KEY_ID`: Your AWS Access Key ID.
- `AWS_SECRET_ACCESS_KEY`: Your AWS Secret Access Key.
- Variables: Add the following variables to your GitHub repository:
- `AWS_REGION`: The region where your ECR and ECS are set up (e.g., `us-east-1`).
- `ECR_REPOSITORY`: The name of your ECR repository.
- `ECS_TASK_DEFINITION`: The ARN of your ECS task definition.
- `ECS_TASK_DEFINITION_PATH`: The path to your ECS task definition file.
- `CONTAINER_NAME`: The name of the container defined in your ECS task definition.
- `ECS_SERVICE`: The name of your ECS service.
- `ECS_CLUSTER`: The name of your ECS cluster.

0 comments on commit f985ebc

Please sign in to comment.