Skip to content

Commit f561610

Browse files
feat: adding buildargs support (#12)
* feat: adding buildargs support * chore: changing typo to build-args and adding support for multiple build-args * chore: updating comment * chore: modify to accept list of argmuments rather than comma separated list * chore: adjusting parsing of buildargs * chore: fixed dockumentation, and changed entrypoing.sh to a bash script --------- Co-authored-by: Geir Arnesen <geir.arnesen@schibsted.no>
1 parent a99be13 commit f561610

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ The Deploy action performs the functions of combining the [Build](https://github
1515
**Optional** Whether to utilise the docker cache during the build. Defaults to true.
1616
### `manifest`
1717
**Optional** Use a custom path for your convox.yml
18+
### `buildargs`
19+
**Optional** Pass docker build arguments to the build process. Build args are key-value pairs separated by a newline:
20+
```
21+
buildargs: |
22+
BASEIMAGE=myimage
23+
MYARG=hello
24+
```
1825

1926

2027
## Example Usage

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ inputs:
2828
manifest:
2929
description: Use a custom path for your convox.yml
3030
required: false
31+
buildargs:
32+
description: Custom build arguments for the Docker build
33+
required: false
3134
runs:
3235
using: docker
3336
image: Dockerfile

entrypoint.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
echo "Deploying"
33
if [ -n "$INPUT_PASSWORD" ]
44
then
@@ -22,4 +22,18 @@ if [ "$INPUT_MANIFEST" != "" ]; then
2222
MANIFEST_COMMAND="-m $INPUT_MANIFEST"
2323
fi
2424

25-
convox deploy --app $INPUT_APP --description "$INPUT_DESCRIPTION" $CACHED_COMMAND $MANIFEST_COMMAND
25+
# Split the INPUT_BUILDARGS by newline into an array
26+
if [ "$INPUT_BUILDARGS" != "" ]; then
27+
IFS=$'\n' read -d '' -r -a ADDR <<< "$INPUT_BUILDARGS" # Split build arguments by newline
28+
29+
for ARG in "${ADDR[@]}"; do
30+
# Extract key and value (handle empty lines or invalid format)
31+
KEY=${ARG%%=*}
32+
VALUE=${ARG#*=}
33+
if [[ -n "$KEY" && -n "$VALUE" ]]; then
34+
BUILDARGS_COMMAND="$BUILDARGS_COMMAND --build-args $KEY=$VALUE"
35+
fi
36+
done
37+
fi
38+
39+
convox deploy --app $INPUT_APP --description "$INPUT_DESCRIPTION" $BUILDARGS_COMMAND $CACHED_COMMAND $MANIFEST_COMMAND

0 commit comments

Comments
 (0)