Skip to content

Build Production Docker Container Image and Push to ECR #2

Build Production Docker Container Image and Push to ECR

Build Production Docker Container Image and Push to ECR #2

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