Skip to content

Commit

Permalink
fix: test if workflow works
Browse files Browse the repository at this point in the history
  • Loading branch information
abelr20 committed Aug 22, 2024
1 parent cb79400 commit 9a9777f
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions .github/workflows/aws.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy to AWS
name: Deploy to AWS ECS

on:
push:
Expand All @@ -9,7 +9,7 @@ concurrency:
cancel-in-progress: true

env:
AWS_REGION: ${{ secrets.AWS_REGION }} # Use GitHub secret for AWS region
AWS_REGION: ${{ secrets.AWS_REGION }} # Use GitHub secrets for AWS region
ECR_REPOSITORY: app # Set this to your Amazon ECR repository name
ECS_SERVICE: SkyDevOps # Set this to your Amazon ECS service name
ECS_CLUSTER: Sky # Set this to your Amazon ECS cluster name
Expand Down Expand Up @@ -41,29 +41,23 @@ jobs:
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Build and push image to AWS ECR
- name: Build and push new Docker image to AWS ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: latest
run: |
# Enable error handling
set -e
set -o pipefail
# Use Docker Buildx to build the image for x86_64
docker buildx build --platform linux/amd64 --push -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Fetch Latest Task Definition ARN
id: fetch-task-def-arn
- name: Deploy to Amazon ECS
run: |
# Fetch the latest task definition for the service
TASK_DEFINITION_ARN=$(aws ecs describe-services \
--cluster ${{ env.ECS_CLUSTER }} \
--services ${{ env.ECS_SERVICE }} \
--query 'services[0].taskDefinition' \
--output text)
echo "TASK_DEFINITION_ARN=$TASK_DEFINITION_ARN" >> $GITHUB_ENV
- name: Deploy to AWS ECS
run: |
# Use the latest task definition revision for the deployment
aws ecs update-service --cluster ${{ env.ECS_CLUSTER }} --service ${{ env.ECS_SERVICE }} --task-definition ${{ env.TASK_DEFINITION_ARN }} --force-new-deployment
# Enable error handling
set -e
set -o pipefail
# Update the ECS service
aws ecs update-service --cluster ${{ env.ECS_CLUSTER }} --service ${{ env.ECS_SERVICE }} --force-new-deployment

0 comments on commit 9a9777f

Please sign in to comment.