feat: add files #10
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 and Deploy images | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
AWS_REGION: ap-northeast-1 | |
ECR_REPOSITORY: petercat | |
ECR_REGISTRY: public.ecr.aws/m5s2b0d4 | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
environment: production | |
strategy: | |
fail-fast: true | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: arn:aws:iam::654654285942:role/Github-OIDC | |
audience: sts.amazonaws.com | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Login to Amazon ECR Public | |
id: login-ecr-public | |
uses: aws-actions/amazon-ecr-login@v2 | |
with: | |
registry-type: public | |
- uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3 | |
- name: Create Docker Cacha Storage Backend | |
run: | | |
docker buildx create --use --driver=docker-container | |
- name: See the file in the runner | |
run: | | |
ls -la | |
- name: Build, tag, and push image to Amazon ECR | |
id: build-image | |
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5 | |
env: | |
IMAGE_TAG: ${{ github.sha }} | |
with: | |
context: ./ | |
push: true | |
platforms: linux/amd64,linux/arm64 | |
tags: ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}, ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:preview | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |