Build docker image and push to ECR. #41
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build & ECR push | |
run-name: Build docker image and push to ECR. | |
on: | |
push: | |
tags: | |
- "v*" | |
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 }} | |
COMMIT_TAG: ${{ github.sha }} | |
GIT_TAG: ${{ github.ref_name }} | |
run: | | |
docker build -t $REGISTRY/$REPOSITORY:$COMMIT_TAG -t $REGISTRY/$REPOSITORY:$GIT_TAG . | |
docker push $REGISTRY/$REPOSITORY:$COMMIT_TAG | |
docker push $REGISTRY/$REPOSITORY:$GIT_TAG |