Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(build-push-to-dockerhub): Expose platforms parameter #37

Merged
merged 5 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions actions/build-push-to-dockerhub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
14 changes: 14 additions & 0 deletions actions/build-push-to-dockerhub/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 }}