diff --git a/.github/workflows/build.yml b/.github/workflows/build-branch.yml similarity index 92% rename from .github/workflows/build.yml rename to .github/workflows/build-branch.yml index 0dffbce..05a0e01 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 branches are pushed -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..a33d907 --- /dev/null +++ b/.github/workflows/build-tag.yml @@ -0,0 +1,49 @@ +name: build dreamkast-weaver image when tags are pushed + +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=sha,prefix=,format=long + 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