Skip to content

Commit

Permalink
Gh action changes (#110)
Browse files Browse the repository at this point in the history
* Modify existing GH Action to only build latest prod image

* Create aws_deploy_prod.yml
  • Loading branch information
BrandonKowalski authored Jan 7, 2025
1 parent 3e66473 commit 04965bd
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 22 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/aws_build_prod_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
on:
push:
branches:
- main
paths-ignore:
- '.github/workflows' # prevent annoying rebuilds while editing workflow configs
workflow_dispatch: # allows for manual trigger via UI/CLI/API

name: Build Production Docker Container Image and Push to ECR

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
environment: production

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Configure AWS credentials
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: us-east-1

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

- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: folio/order-import-poc
IMAGE_TAG: 'latest'
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
on:
push:
branches:
- main
workflow_dispatch: # allows for manual trigger via UI/CLI/API

name: Deploy to Amazon ECS
workflow_dispatch: # can only be launched manually
name: Deploy New TD on ECS

jobs:
deploy:
Expand All @@ -23,24 +19,10 @@ jobs:
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

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

- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: folio/order-import-poc
IMAGE_TAG: ${{ github.sha }}
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
- name: Fill in the execution role ARN in the Amazon ECS task definition
id: task-def-exec-arn
uses: microsoft/variable-substitution@v1
Expand All @@ -52,10 +34,14 @@ jobs:
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: folio/order-import-poc
IMAGE_TAG: 'latest'
with:
task-definition: task-definition.json
container-name: oimp-poc
image: ${{ steps.build-image.outputs.image }}
image: ${{ $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG }}

- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
Expand All @@ -64,3 +50,4 @@ jobs:
service: oimp-poc
cluster: tf-folio-oimp-dev-cluster
wait-for-service-stability: true

0 comments on commit 04965bd

Please sign in to comment.