Skip to content

Commit

Permalink
Add upload-image workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
naru200 committed May 2, 2024
1 parent b74fcd0 commit b935813
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/upload-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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

0 comments on commit b935813

Please sign in to comment.