forked from archived-shomeya/dokku-deploydata
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost-release-buildpack
More file actions
executable file
·22 lines (18 loc) · 1.1 KB
/
post-release-buildpack
File metadata and controls
executable file
·22 lines (18 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env bash
# Adds a file called `deploydata.json` to the repository
# the contents will information about the deployment
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"; IMAGE="dokku/$APP"
# Gather the data
BRANCH=$(GIT_DIR=$DOKKU_ROOT/$APP git rev-parse --abbrev-ref HEAD)
BUILD_DATE=$(date)
BUILD_HOST=$(hostname --fqdn)
BUILD_USER=$(whoami)
COMMIT_AUTHOR=$(GIT_DIR=$DOKKU_ROOT/$APP git log -1 --pretty=%an)
COMMIT_DATE=$(GIT_DIR=$DOKKU_ROOT/$APP git log -1 --pretty=%ad)
COMMIT_MESSAGE=$(GIT_DIR=$DOKKU_ROOT/$APP git log -1 --pretty=%s)
COMMIT_SHA=$(GIT_DIR=$DOKKU_ROOT/$APP git rev-parse HEAD)
# Write the data to deploydata.json inside container and commit new layer
id=$(printf '{"branch": "%s","build_date": "%s","buildhost": "%s","builduser": "%s","commit_author": "%s","commit_date": "%s","commit_message": "%s","commit_sha": "%s"}\n' "$BRANCH" "$BUILD_DATE" "$BUILD_HOST" "$BUILD_USER" "$COMMIT_AUTHOR" "$COMMIT_DATE" "$COMMIT_MESSAGE" "$COMMIT_SHA" | docker run -i -a stdin $IMAGE /bin/bash -c "cat > /app/deploydata.json")
test $(docker wait $id) -eq 0
docker commit $id $IMAGE > /dev/null