Skip to content

Build docker image and push to ECR. #20

Build docker image and push to ECR.

Build docker image and push to ECR. #20

Workflow file for this run

name: Build & ECR push
run-name: Build docker image and push to ECR.
on:
push:
branches:
- main
- gh-action
env:
AWS_REGION: ap-northeast-1
permissions:
id-token: write
jobs:
BuildImage:
runs-on: ubuntu-22.04
steps:
- name: Check out repository code
uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.GH_ACTION_ROLE_NAME }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build, tag, and push docker image to Amazon ECR
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: ${{ secrets.REPOSITORY }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG