From ab1bb9d26584849deff6ef4dd3a7755e7527d675 Mon Sep 17 00:00:00 2001 From: Chris Vest Date: Mon, 29 Dec 2025 13:08:04 +0100 Subject: [PATCH] Add GitHub Actions workflow for AWS ECR deployment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This workflow automates building and pushing Docker images to AWS ECR: - Triggers on PR events and manual dispatch - Multi-platform builds (linux/amd64, linux/arm64) - Automated tagging based on branch and SHA - GitHub Actions cache for faster builds 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- .github/workflows/build-push-ecr.yml | 62 ++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/build-push-ecr.yml diff --git a/.github/workflows/build-push-ecr.yml b/.github/workflows/build-push-ecr.yml new file mode 100644 index 0000000..4915375 --- /dev/null +++ b/.github/workflows/build-push-ecr.yml @@ -0,0 +1,62 @@ +name: Build and Push to AWS ECR + +on: + pull_request: + types: [opened, synchronize, reopened, closed] + workflow_dispatch: + +env: + AWS_REGION: us-east-1 + ECR_REPOSITORY: zerodev/passkey-server + +permissions: + contents: write + id-token: write + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: arn:aws:iam::117243983517:role/zerodev-gha + role-session-name: GitHubActions-${{ github.run_id }} + aws-region: ${{ env.AWS_REGION }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + with: + registries: "352956043285" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }} + tags: | + type=sha,prefix=${{ github.event.pull_request.head.ref }}-,enable={{is_not_default_branch}} + type=sha,prefix=,enable={{is_default_branch}} + type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max