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

update inputs to build-push-to-dockerhub action #143

Merged
Show file tree
Hide file tree
Changes from 5 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
20 changes: 12 additions & 8 deletions actions/build-push-to-dockerhub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,18 @@ jobs:

## 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) |
| `file` | String | Path and filename of the dockerfile to build from. (Default: `{context}/Dockerfile`) |
| 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) |
| `file` | String | Path and filename of the dockerfile to build from. (Default: `{context}/Dockerfile`) |
| `build-args` | String | List of arguments necessary for the Docker image to be built. |
| `target` | String | Sets the target stage to build |
| `cache-from` | String | Where cache should be fetched from ([more about GHA and container caching](https://www.kenmuse.com/blog/implementing-docker-layer-caching-in-github-actions/)) |
| `cache-to` | String | Where cache should be stored to ([more about GHA and container caching](https://www.kenmuse.com/blog/implementing-docker-layer-caching-in-github-actions/)) |

[mda]: https://github.com/docker/metadata-action?tab=readme-ov-file#tags-input

Expand Down
29 changes: 27 additions & 2 deletions actions/build-push-to-dockerhub/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,36 @@ inputs:
description: |
The dockerfile to use.
required: false
build-args:
description: |
List of arguments necessary for the Docker image to be built.
required: false
default: ""
target:
description: |
Target stage to build
required: false
cache-from:
description: |
Where cache should be fetched from
required: false
default: "type=gha"
cache-to:
description: |
Where cache should be stored to
required: false
default: "type=gha,mode=max"

runs:
using: composite
steps:
# See this conversation for more context as to why we don't want to allow pushes on pull requests
# https://github.com/grafana/shared-workflows/pull/143#discussion_r1628314620
- name: Check if push is allowed
if: ${{ inputs.push == 'true' && github.event_name != 'push' }}
if: ${{ inputs.push == 'true' && github.event_name != 'pull_request' }}
joeyorlando marked this conversation as resolved.
Show resolved Hide resolved
shell: sh
run: |
>&2 echo "Publishing to DockerHub is only allowed on push events."
>&2 echo "Publishing to DockerHub is not allowed on pull_request events."
>&2 echo "If you still want to build images without pushing them, set the push input to false."
exit 1

Expand Down Expand Up @@ -79,3 +100,7 @@ runs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: ${{ inputs.file }}
build-args: ${{ inputs.build-args }}
target: ${{ inputs.target }}
cache-from: ${{ inputs.cache-from }}
cache-to: ${{ inputs.cache-to }}
Loading