Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ci: update Amazon ECR ci #250

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading