diff --git a/.github/workflows/aws-ecr-docker.yml b/.github/workflows/aws-ecr-docker.yml new file mode 100644 index 0000000000..b0eb3a00c1 --- /dev/null +++ b/.github/workflows/aws-ecr-docker.yml @@ -0,0 +1,80 @@ +# SPDX-License-Identifier: BUSL-1.1 +# +# Copyright (C) 2023, Berachain Foundation. All rights reserved. +# Use of this software is govered by the Business Source License included +# in the LICENSE file of this repository and at www.mariadb.com/bsl11. +# +# ANY USE OF THE LICENSED WORK IN VIOLATION OF THIS LICENSE WILL AUTOMATICALLY +# TERMINATE YOUR RIGHTS UNDER THIS LICENSE FOR THE CURRENT AND ALL OTHER +# VERSIONS OF THE LICENSED WORK. +# +# THIS LICENSE DOES NOT GRANT YOU ANY RIGHT IN ANY TRADEMARK OR LOGO OF +# LICENSOR OR ITS AFFILIATES (PROVIDED THAT YOU MAY USE A TRADEMARK OR LOGO OF +# LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). +# +# TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON +# AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, +# EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND +# TITLE. + +name: "aws-ecr-docker" + +on: + push: + # tags: + branches: + - '**' + +permissions: + contents: read + +jobs: + build-push-docker: + runs-on: polaris-linux-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v3 # More information on this action can be found below in the 'AWS Credentials' section + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-2 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + with: + mask-password: "true" + run: | + aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/d4k0c7i3 + + - name: Build, tag, push amd64 docker image to Amazon ECR + env: + IMAGE_TAG: ${{ github.sha }} + GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + docker build --platform linux/amd64 -f ./build/docker/beacond.Dockerfile -t beacond:v0.0.0 --build-arg GIT_TOKEN=$GIT_TOKEN --build-arg GOARCH=amd64 . + docker tag beacond:v0.0.0 public.ecr.aws/d4k0c7i3/beacond:amd64-$IMAGE_TAG + docker push public.ecr.aws/d4k0c7i3/beacond:amd64-$IMAGE_TAG + docker tag beacond:v0.0.0 public.ecr.aws/d4k0c7i3/beacond:amd64-latest + docker push public.ecr.aws/d4k0c7i3/beacond:amd64-latest + + - name: Build, tag, push arm64 docker image to Amazon ECR + env: + IMAGE_TAG: ${{ github.sha }} + GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + docker buildx build --platform linux/arm64 -f ./build/docker/beacond.Dockerfile -t beacond:v0.0.0 --build-arg GIT_TOKEN=$GIT_TOKEN --build-arg GOARCH=arm64 . + docker tag beacond:v0.0.0 public.ecr.aws/d4k0c7i3/beacond:arm64-$IMAGE_TAG + docker push public.ecr.aws/d4k0c7i3/beacond:arm-$IMAGE_TAG + docker tag beacond:v0.0.0 public.ecr.aws/d4k0c7i3/beacond:arm64-latest + docker push public.ecr.aws/d4k0c7i3/beacond:arm-latest