Skip to content

Commit

Permalink
feat: support build-contexts for docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
gopkri24 committed Oct 23, 2024
1 parent 574f29a commit 335163e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions container-scan/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ To use this action in your GitHub Actions workflow, include the following steps:
| image-tag | Docker image tag | `true` | |
| image-platform | Target platform to build image for (eg. linux/amd64 (default), linux/arm64, etc) | `false` | linux/amd64 |
| build-args | List of build arguments for docker build as key-value pairs (e.g., KEY=VALUE) | `false` | |
| build-contexts | List of additional build contexts (e.g., name=path) | `false` | |
| secrets | List of secrets for docker build as key-value pairs (e.g., SECRET_KEY=VALUE) | `false` | |
| enable-docker-build | Docker image tag | `false` | true |
<!-- action-docs-inputs -->
Expand Down
6 changes: 5 additions & 1 deletion container-scan/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ inputs:
description: Target platform to build image for (eg. linux/amd64 (default), linux/arm64, etc)
required: false
default: linux/amd64

build-args:
required: false
description: List of build arguments for docker build as key-value pairs (e.g., KEY=VALUE)
default: ""
build-contexts:
required: false
description: List of additional build contexts (e.g., name=path)
default: ""
secrets:
required: false
description: List of secrets for docker build as key-value pairs (e.g., SECRET_KEY=VALUE)
Expand Down Expand Up @@ -74,6 +77,7 @@ runs:
type=ref,event=branch
type=ref,event=pr
build-args: ${{ inputs.build-args }}
build-contexts: ${{ inputs.build-contexts }}
secrets: ${{ inputs.secrets }}

- name: "Determining image name"
Expand Down
8 changes: 6 additions & 2 deletions docker-build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ steps:
type=semver,pattern={{version}},value=${{ steps.release.outputs.new-release-version }}
```
#### Dynamically input multiple build arguments and secrets:
#### Dynamically input multiple build arguments, contexts and secrets:
If you want to pass multiple build arguments and secrets, you can use the `build-args` and `secrets` input parameters.
If you want to pass multiple build arguments and secrets, you can use the `build-args`, `build-contexts` and `secrets` input parameters.

```yaml
steps:
Expand All @@ -74,6 +74,9 @@ steps:
build-args: |
KEY1=VALUE1
KEY2=VALUE2
build-contexts: |
context1=PATH1
context2=PATH2
secrets: |
SECRET_KEY1=SECRET_VALUE1
SECRET_KEY2=SECRET_VALUE2
Expand All @@ -98,6 +101,7 @@ steps:
| push | Do you want to push the image to the registry | `false` | false |
| load | Do you want to load the single-platform build result to docker images | `false` | true |
| build-args | List of build arguments as key-value pairs (e.g., KEY=VALUE) | `false` | |
| build-contexts | List of additional build contexts (e.g., name=path) | `false` | |
| secrets | List of secrets as key-value pairs (e.g., SECRET_KEY=VALUE) | `false` | |

## Outputs
Expand Down
6 changes: 6 additions & 0 deletions docker-build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ inputs:
required: false
description: List of build arguments as key-value pairs (e.g., KEY=VALUE)
default: ""
build-contexts:
required: false
description: List of additional build contexts (e.g., name=path)
default: ""
secrets:
required: false
description: List of secrets as key-value pairs (e.g., SECRET_KEY=VALUE)
Expand Down Expand Up @@ -115,3 +119,5 @@ runs:
labels: ${{ steps.meta.outputs.labels }}
secrets: |
${{ inputs.secrets }}
build-contexts: |
${{ inputs.build-contexts }}

0 comments on commit 335163e

Please sign in to comment.