Skip to content

Create upload-image.yaml #1

Create upload-image.yaml

Create upload-image.yaml #1

Workflow file for this run

name: Push to ECR
on:
push:
branches:
- main
- complete
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ap-northeast-2
role-to-assume: arn:aws:iam::123456789100:role/my-github-actions-role
- 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: github-actions-hands-on
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG ./
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG