Add option to source env from file
All checks were successful
ci/woodpecker/pr/lint Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/test/1 Pipeline was successful
ci/woodpecker/pr/test/2 Pipeline was successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/dockerhub Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/test/1 Pipeline was successful
ci/woodpecker/push/test/2 Pipeline was successful

This commit is contained in:
Stephan Schnabel 2025-06-24 21:12:16 +02:00
parent 8aa00208d3
commit 9769ea1ba4
Signed by: stephan.schnabel
SSH key fingerprint: SHA256:99zuzxNGFb5/5P+E/O7ONU2qhUojUe/D8rIPTW+9Xp0
2 changed files with 10 additions and 0 deletions

View file

@ -86,6 +86,7 @@ docker run --rm --user=$(id -u) --volume=$HOME:$HOME:ro --workdir=$PWD --env=PLU
| `annotation` | PLUGIN_ANNOTATION | `none` | Annotations (also known as labels) to add to image | | `annotation` | PLUGIN_ANNOTATION | `none` | Annotations (also known as labels) to add to image |
| `push` | PLUGIN_PUSH | `true` | Push images if output names are set. | | `push` | PLUGIN_PUSH | `true` | Push images if output names are set. |
| `auth` | PLUGIN_AUTH | `none` | Auth for private registries | | `auth` | PLUGIN_AUTH | `none` | Auth for private registries |
| `env-file` | PLUGIN_ENV_FILE | `none` | Source environment values from given file |
## Alternatives ## Alternatives

View file

@ -5,6 +5,15 @@ set -eu;
## check input ## check input
## ##
if [[ -n "${PLUGIN_ENV_FILE:-}" ]]; then
if [[ ! -f "PLUGIN_ENV_FILE" ]]; then
echo "Env file $PLUGIN_ENV_FILE not found."
exit 1
fi
# shellcheck source=/dev/null
source "$PLUGIN_ENV_FILE"
fi
BUILDCTL_CONTEXT=${PLUGIN_CONTEXT:-$(pwd)} BUILDCTL_CONTEXT=${PLUGIN_CONTEXT:-$(pwd)}
BUILDCTL_DOCKERFILE=$(dirname "${PLUGIN_DOCKERFILE:-$BUILDCTL_CONTEXT/Dockerfile}") BUILDCTL_DOCKERFILE=$(dirname "${PLUGIN_DOCKERFILE:-$BUILDCTL_CONTEXT/Dockerfile}")
if [[ ! -f $BUILDCTL_DOCKERFILE/Dockerfile ]]; then if [[ ! -f $BUILDCTL_DOCKERFILE/Dockerfile ]]; then