diff --git a/actions/build-push-to-dockerhub/README.md b/actions/build-push-to-dockerhub/README.md index 3b50536b..788a9b24 100644 --- a/actions/build-push-to-dockerhub/README.md +++ b/actions/build-push-to-dockerhub/README.md @@ -28,3 +28,20 @@ jobs: "2024-04-01-abcd1234" "latest" ``` + +## Inputs + +| Name | Type | Description | +|------|------|-------------| +| `context` | String | Path to the Dockerfile (default: `.`) | +| `platforms` | List | List of platforms the image should be built for (e.g. `linux/amd64,linux/arm64`) | +| `push` | Bool | Push the generated image (default: `false`) | +| `repository`| String | Docker repository name | +| `tags` | List | Tags that should be used for the image (see the [metadata-action][mda] for details) | + +[mda]: https://github.com/docker/metadata-action?tab=readme-ov-file#tags-input + + +## Notes + +- If you specify `platforms` then the action will use buildx to build the image. diff --git a/actions/build-push-to-dockerhub/action.yaml b/actions/build-push-to-dockerhub/action.yaml index 07ba473e..c6789a3c 100644 --- a/actions/build-push-to-dockerhub/action.yaml +++ b/actions/build-push-to-dockerhub/action.yaml @@ -13,6 +13,10 @@ inputs: description: | Path to Dockerfile, which is used to build the image. default: "." + platforms: + description: | + List of platforms to build the image for + required: false push: description: | Push the generated images also to DockerHub @@ -24,6 +28,15 @@ runs: - name: Check out the repo uses: actions/checkout@v4 + # If platforms is specified then also initialize buildx and qemu: + - name: Set up QEMU + if: inputs.platforms + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + if: inputs.platforms + uses: docker/setup-buildx-action@v3 + - name: Get secrets for DockerHub login id: get-secrets uses: grafana/shared-workflows/actions/get-vault-secrets@main @@ -49,6 +62,7 @@ runs: uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 with: context: ${{ inputs.context }} + platforms: ${{ inputs.platforms }} push: ${{ inputs.push }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }}