forked from lost-pixel/lost-pixel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·67 lines (58 loc) · 2.3 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/sh
WORKSPACE=${WORKSPACE:-$PWD}
export CI_BUILD_ID=${GITHUB_RUN_ID:-$CI_BUILD_ID}
export CI_BUILD_NUMBER=${GITHUB_RUN_NUMBER:-$CI_BUILD_NUMBER}
export EVENT_PATH=${GITHUB_EVENT_PATH:-$EVENT_PATH}
export REPOSITORY=${GITHUB_REPOSITORY:-$REPOSITORY}
export CACHE_KEY="${INPUT_CACHE_KEY:-$LOST_PIXEL_CACHE_KEY}"
export COMMIT_SHA=${GITHUB_SHA}
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
export COMMIT_REF_NAME=${GITHUB_HEAD_REF:-$COMMIT_REF_NAME}
if [ -f "$EVENT_PATH" ]; then
PR_COMMIT_SHA=$(cat $EVENT_PATH | grep -oP '(?<="after": ")[^"]*')
PR_HEAD_SHA=$(cat $EVENT_PATH | jq -r .pull_request.head.sha)
fi
if [ -n "${PR_COMMIT_SHA}" ] && [ "$PR_COMMIT_SHA" != "null" ]; then
export COMMIT_HASH=${PR_COMMIT_SHA:-$COMMIT_HASH}
elif [ -n "${PR_HEAD_SHA}" ] && [ "$PR_HEAD_SHA" != "null" ]; then
export COMMIT_HASH=${PR_HEAD_SHA:-$COMMIT_HASH}
else
export COMMIT_HASH=${GITHUB_SHA:-$COMMIT_HASH}
fi
else
export COMMIT_REF_NAME=${GITHUB_REF_NAME:-$COMMIT_REF_NAME}
export COMMIT_HASH=${GITHUB_SHA:-$COMMIT_HASH}
fi
echo Environment:
[ -z "${WORKSPACE}" ] || echo "WORKSPACE=$WORKSPACE"
[ -z "${CI_BUILD_ID}" ] || echo "CI_BUILD_ID=$CI_BUILD_ID"
[ -z "${CI_BUILD_NUMBER}" ] || echo "CI_BUILD_NUMBER=$CI_BUILD_NUMBER"
[ -z "${EVENT_PATH}" ] || echo "EVENT_PATH=$EVENT_PATH"
[ -z "${COMMIT_HASH}" ] || echo "COMMIT_HASH=$COMMIT_HASH"
[ -z "${COMMIT_SHA}" ] || echo "COMMIT_SHA=$COMMIT_SHA"
[ -z "${PR_COMMIT_SHA}" ] || echo "PR_COMMIT_SHA=$PR_COMMIT_SHA"
[ -z "${PR_HEAD_SHA}" ] || echo "PR_HEAD_SHA=$PR_HEAD_SHA"
[ -z "${COMMIT_REF_NAME}" ] || echo "COMMIT_REF_NAME=$COMMIT_REF_NAME"
[ -z "${REPOSITORY}" ] || echo "REPOSITORY=$REPOSITORY"
[ -z "${CACHE_KEY}" ] || echo "CACHE_KEY=$CACHE_KEY"
echo
cd $WORKSPACE
if [ "$INPUT_FINALIZE" = "true" ] || [ "$INPUT_FINALIZE" = "1" ]; then
CI_BUILD_ID="$CI_BUILD_ID" \
CI_BUILD_NUMBER="$CI_BUILD_NUMBER" \
EVENT_PATH="$EVENT_PATH" \
COMMIT_HASH="$COMMIT_HASH" \
COMMIT_REF_NAME="$COMMIT_REF_NAME" \
REPOSITORY="$REPOSITORY" \
LOST_PIXEL_CACHE_KEY="$CACHE_KEY" \
lost-pixel finalize $@
else
CI_BUILD_ID="$CI_BUILD_ID" \
CI_BUILD_NUMBER="$CI_BUILD_NUMBER" \
EVENT_PATH="$EVENT_PATH" \
COMMIT_HASH="$COMMIT_HASH" \
COMMIT_REF_NAME="$COMMIT_REF_NAME" \
REPOSITORY="$REPOSITORY" \
LOST_PIXEL_CACHE_KEY="$CACHE_KEY" \
lost-pixel $@
fi