Skip to content

Change name

Change name #80

Workflow file for this run

name: Build, Push, and Deploy
on:
push:
branches:
- dev
- master
- gamma
jobs:
build-and-push:
name: Build and Push
runs-on: ubuntu-latest
environment: ${{ github.ref == 'refs/heads/master' && 'prod' || (github.ref == 'refs/heads/dev' && 'dev' || 'staging') }}
permissions:
id-token: write
contents: read
env:
AWS_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
IMAGE_TAG: ${{ github.sha }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
docker build \
-t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \
-t $ECR_REGISTRY/$ECR_REPOSITORY:latest \
-f build/docker/Dockerfile .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
update-ecs-service:
name: Update ECS Service
runs-on: ubuntu-latest
needs: build-and-push
environment: ${{ github.ref == 'refs/heads/master' && 'prod' || (github.ref == 'refs/heads/dev' && 'dev' || 'staging') }}
permissions:
id-token: write
contents: read
env:
AWS_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
ECS_CLUSTER: ${{ secrets.ECS_NAME }}
ECS_SERVICE: ${{ secrets.ECS_NAME }}
IMAGE: ${{ needs.build-and-push.outputs.image }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
- name: Update ECS service
run: |
aws ecs update-service \
--cluster $ECS_CLUSTER \
--service $ECS_SERVICE \
--force-new-deployment \
--region $AWS_REGION \
--no-cli-pager \
> /dev/null 2>&1
echo "Started Deployment"