Skip to content

Commit

Permalink
Merge pull request #250 from Marukome0743/pr250
Browse files Browse the repository at this point in the history
♻️ci: update Amazon ECR ci
  • Loading branch information
Marukome0743 authored Apr 19, 2024
2 parents aa79d78 + ba6a8aa commit cdc5412
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions .github/workflows/push-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ env:
GHCR_REGISTRY: ghcr.io
GHCR_REPOSITORY: openup-labtakizawa/homepage
AWS_REGION: ap-northeast-1
ECR_REGISTRY: 544280698279.dkr.ecr.ap-northeast-1.amazonaws.com
ECR_REPOSITORY: homepage
LAMBDA_FUNCTION_NAME: homepage
IS_PUSH: ${{ inputs.push || github.event_name == 'push' && github.repository_owner == 'OpenUp-LabTakizawa' && github.ref_name == 'main' }}
Expand Down Expand Up @@ -79,9 +78,8 @@ jobs:

- name: Login to Amazon ECR
if: env.IS_PUSH
uses: docker/login-action@v3
with:
registry: ${{ env.ECR_REGISTRY }}
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Docker Meta
id: meta
Expand All @@ -90,7 +88,6 @@ jobs:
images: |
${{ env.REPOSITORY }}
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_REPOSITORY }}
${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}
tags: |
type=ref,event=tag
type=ref,event=pr,prefix=pr-
Expand All @@ -112,11 +109,16 @@ jobs:
cache-to: type=gha,mode=max
provenance: false

# - name: Update AWS Lambda Function
# if: env.IS_PUSH
# run: |
# aws lambda update-function-code --function-name ${{ env.LAMBDA_FUNCTION_NAME }} \
# --image-uri ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ steps.meta.outputs.version }}
- name: Build and Push Image to Amazon ECR
if: env.IS_PUSH
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker build --platform linux/arm64 -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
aws lambda update-function-code --function-name $LAMBDA_FUNCTION_NAME \
--architectures arm64 --image-uri $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: Docker Scout
if: github.repository_owner == 'OpenUp-LabTakizawa' && github.event_name == 'pull_request_target'
Expand Down

0 comments on commit cdc5412

Please sign in to comment.