From 048d54fdd1df1d9aee18075cf433be645f6d763d Mon Sep 17 00:00:00 2001 From: ShotaKitazawa Date: Sun, 14 Apr 2024 21:53:17 +0900 Subject: [PATCH] separate build Action --- .../workflows/{build.yml => build-branch.yml} | 8 ++-- .github/workflows/build-tag.yml | 48 +++++++++++++++++++ 2 files changed, 53 insertions(+), 3 deletions(-) rename .github/workflows/{build.yml => build-branch.yml} (93%) create mode 100644 .github/workflows/build-tag.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build-branch.yml similarity index 93% rename from .github/workflows/build.yml rename to .github/workflows/build-branch.yml index 0dffbce..e5c8412 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build-branch.yml @@ -1,6 +1,8 @@ -name: build dreamkast-weaver image +name: build dreamkast-weaver image when pushed branches -on: push +on: + push: + branches: ["*"] jobs: build: @@ -18,7 +20,7 @@ jobs: with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ap-northeast-1 + aws-region: us-west-2 - name: Login to Amazon ECR id: login-ecr diff --git a/.github/workflows/build-tag.yml b/.github/workflows/build-tag.yml new file mode 100644 index 0000000..4a5bdc2 --- /dev/null +++ b/.github/workflows/build-tag.yml @@ -0,0 +1,48 @@ +name: build dreamkast-weaver image when pushed tags + +on: + push: + tags: ["*"] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ap-northeast-1 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ steps.login-ecr.outputs.registry }}/dreamkast-weaver + tags: | + type=ref,event=tag + + - name: Build + id: docker_build + uses: docker/build-push-action@v5 + with: + context: ./ + file: Dockerfile + builder: ${{ steps.buildx.outputs.name }} + push: true + provenance: false + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max