feat: read built timestamp from git
This commit is contained in:
parent
097ebfaf38
commit
d460532cb8
3 changed files with 29 additions and 16 deletions
|
@ -6,6 +6,10 @@
|
||||||
FROM docker.io/library/bash:5.2.37@sha256:01a15c6f48f6a3c08431cd77e11567823530b18159889dca3b7309b707beef91
|
FROM docker.io/library/bash:5.2.37@sha256:01a15c6f48f6a3c08431cd77e11567823530b18159889dca3b7309b707beef91
|
||||||
SHELL ["/usr/local/bin/bash", "-u", "-e", "-o", "pipefail", "-c"]
|
SHELL ["/usr/local/bin/bash", "-u", "-e", "-o", "pipefail", "-c"]
|
||||||
|
|
||||||
|
# workaround until we have a env `CI_COMMIT_TIMESTAMP`
|
||||||
|
# see https://github.com/woodpecker-ci/woodpecker/issues/5245
|
||||||
|
RUN apk add git~=2 --no-cache
|
||||||
|
|
||||||
RUN ARCH=$(uname -m) && \
|
RUN ARCH=$(uname -m) && \
|
||||||
[[ $ARCH == x86_64 ]] && export SUFFIX=amd64; \
|
[[ $ARCH == x86_64 ]] && export SUFFIX=amd64; \
|
||||||
[[ $ARCH == aarch64 ]] && export SUFFIX=arm64; \
|
[[ $ARCH == aarch64 ]] && export SUFFIX=arm64; \
|
||||||
|
|
30
README.md
30
README.md
|
@ -72,21 +72,21 @@ docker run --rm --user=$(id -u) --volume=$HOME:$HOME:ro --workdir=$PWD --env=PLU
|
||||||
|
|
||||||
## Settings
|
## Settings
|
||||||
|
|
||||||
| Settings Name | Environment | Default | Description |
|
| Settings Name | Environment | Default | Description |
|
||||||
| ------------------- | ------------------------ | ---------------- | ----------------------------------------------------------------------------------------------- |
|
| ------------------- | ------------------------ | --------------------------- | -------------------------------------------------- |
|
||||||
| `addr` | PLUGIN_ADDR | `$BUILDKIT_HOST` | Buildkit host to use. |
|
| `addr` | PLUGIN_ADDR | `$BUILDKIT_HOST` | Buildkit host to use. |
|
||||||
| `frontend` | PLUGIN_FRONTEND | `dockerfile.v0` | Only dockerfile frontend supported right now |
|
| `frontend` | PLUGIN_FRONTEND | `dockerfile.v0` | Only dockerfile frontend supported right now |
|
||||||
| `context` | PLUGIN_CONTEXT | `$PWD` | Context directory to use for build |
|
| `context` | PLUGIN_CONTEXT | `$PWD` | Context directory to use for build |
|
||||||
| `dockerfile` | PLUGIN_DOCKERFILE | `Dockerfile` | Dockerfile to use. |
|
| `dockerfile` | PLUGIN_DOCKERFILE | `Dockerfile` | Dockerfile to use. |
|
||||||
| `target` | PLUGIN_TARGET | `none` | Dockerfile target |
|
| `target` | PLUGIN_TARGET | `none` | Dockerfile target |
|
||||||
| `build-args` | PLUGIN_BUILD_ARGS | `none` | Build args to pass to build |
|
| `build-args` | PLUGIN_BUILD_ARGS | `none` | Build args to pass to build |
|
||||||
| `platform` | PLUGIN_PLATFORM | `none` | Target platform for container image. |
|
| `platform` | PLUGIN_PLATFORM | `none` | Target platform for container image. |
|
||||||
| `source-epoch-date` | PLUGIN_SOURCE_DATE_EPOCH | `0` | Timestamp to use for reproduceable builds. |
|
| `source-epoch-date` | PLUGIN_SOURCE_DATE_EPOCH | `git log -1 --format="%at"` | Timestamp to use for reproduceable builds. |
|
||||||
| `name` | PLUGIN_NAME | `none` | Images names where to push the image. |
|
| `name` | PLUGIN_NAME | `none` | Images names where to push the image. |
|
||||||
| `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 |
|
| `env-file` | PLUGIN_ENV_FILE | `none` | Source environment values from given file |
|
||||||
|
|
||||||
## Alternatives
|
## Alternatives
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,15 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -eu;
|
set -eu;
|
||||||
|
|
||||||
|
##
|
||||||
|
## workaround until we have a env `CI_COMMIT_TIMESTAMP`
|
||||||
|
## see https://github.com/woodpecker-ci/woodpecker/issues/5245
|
||||||
|
##
|
||||||
|
|
||||||
|
if [[ -z "${CI_COMMIT_TIMESTAMP:-}" ]]; then
|
||||||
|
CI_COMMIT_TIMESTAMP=$(git log -1 --format="%at")
|
||||||
|
fi
|
||||||
|
|
||||||
##
|
##
|
||||||
## check input
|
## check input
|
||||||
##
|
##
|
||||||
|
@ -27,7 +36,7 @@ if [[ "$BUILDCTL_FRONTEND" != "dockerfile.v0" ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SOURCE_DATE_EPOCH=${PLUGIN_SOURCE_DATE_EPOCH:-0}
|
SOURCE_DATE_EPOCH=${PLUGIN_SOURCE_DATE_EPOCH:-${CI_COMMIT_TIMESTAMP:-0}}
|
||||||
|
|
||||||
if [[ -n "${PLUGIN_AUTH:-}" ]]; then
|
if [[ -n "${PLUGIN_AUTH:-}" ]]; then
|
||||||
echo "$PLUGIN_AUTH" | jq -r 'to_entries|map({(.key):{"auth":(.value.username+":"+.value.password)|@base64}})|add|{"auths":.}' > "$HOME/.docker/config.json"
|
echo "$PLUGIN_AUTH" | jq -r 'to_entries|map({(.key):{"auth":(.value.username+":"+.value.password)|@base64}})|add|{"auths":.}' > "$HOME/.docker/config.json"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue