Skip to content

Commit

Permalink
Add Docker Qemu build action
Browse files Browse the repository at this point in the history
  • Loading branch information
bbharathkumarreddy committed Jun 4, 2024
1 parent 7763f25 commit 09990df
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 1 deletion.
Empty file added .gitignore
Empty file.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright [2024] [bbharathkumarreddy96@gmail.com]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,47 @@
# docker-qemu-buildx-ecr-action

Docker QEMU Buildx ECR Action - supports multi platform builds including linux/arm64 and ECR Push

## Usage

```yaml
name: ci

on:
push:

jobs:
qemu:
runs-on: ubuntu-latest
steps:
- name: Docker QEMU Buildx ECR
uses: bbharathkumarreddy/docker-qemu-buildx-ecr-action
with:
platform: linux/arm64
ecr-push: true
aws-access-key-id: ${{ secrets.aws-access-key-id }}
aws-secret-access-key: ${{ secrets.aws-secret-access-key }}
aws-region: ${{ vars.aws-region }}
ecr-repository: my-service
ecr-tag: latest
```
## Customizing
### inputs
The following inputs can be used as `step.with` keys:

| Name | Type | Default | Description |
| ----------------------- | ------- | ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `platform` | String | [`linux/arm64`](https://docs.docker.com/build/building/multi-platform/) | Platform architecture to build. |
| `ecr-push` | Boolean | `true` | Set to `true` to push the docker build to ECR repository. `aws.*` and `ecr.*` inputs to be given if set to `true`. |
| `aws-access-key-id` | String | | Pass the AWS access key id. |
| `aws-secret-access-key` | String | | Pass the AWS secret access key. |
| `aws-region` | String | | Pass the AWS region of the ECR repository. |
| `ecr-repository` | String | | Pass the ECR repository name. |
| `ecr-tag` | String | `latest` | Pass ECR tag to push. |

## Contributing

Want to contribute? ✅
70 changes: 70 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: "Docker QEMU Buildx ECR Action"
description: "Docker QEMU Buildx ECR Action - supports multi platform builds including linux/arm64 and ECR Push"
author: "bbharathkumarreddy@96@gmail.com"
branding:
icon: "package"
color: "blue"

inputs:
platform:
description: "Platform architecture to build."
default: "linux/arm64"
required: false
ecr-push:
description: "ECR push."
default: "true"
required: false
aws-access-key-id:
description: "AWS access key id."
required: false
aws-secret-access-key:
description: "AWS Secret access key."
required: false
aws-region:
description: "AWS region of the ECR repository."
required: false
ecr-repository:
description: "ECR repository name."
required: false
ecr-tag:
description: "AWS region."
default: "latest"
required: false

runs:
using: "composite"
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Configure AWS credentials
if: ${{ inputs.ecr-push == 'true' }}
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ inputs.aws-access-key-id }}
aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
aws-region: ${{ inputs.aws-region }}

- name: Login to Amazon ECR
if: ${{ inputs.ecr-push == 'true' }}
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: ECR Build and push
uses: docker/build-push-action@v5
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ inputs.ecr-repository }}
IMAGE_TAG: ${{ inputs.ecr-tag }}
AWS_REGION: ${{ inputs.aws-region }}
with:
push: ${{ inputs.ecr-push }}
context: .
platforms: ${{ inputs.platform }}
tags: ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
provenance: false
cache-from: type=gha
cache-to: type=gha,mode=max

0 comments on commit 09990df

Please sign in to comment.