-
Notifications
You must be signed in to change notification settings - Fork 0
/
nullplatform-asset-lambda-build.yml
88 lines (81 loc) · 2.5 KB
/
nullplatform-asset-lambda-build.yml
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
spec:
inputs:
ci-image:
ci-before-script:
command:
default: make
arguments:
default: build
options:
default: ""
build-working-directory:
default: .
asset-working-directory:
default: .
asset-output-directory:
default: build
asset-name:
default: main
---
stages:
- nullplatform-asset-lambda-build
variables:
RUNNER_TAG: $RUNNER_TAG
NULLPLATFORM_API_KEY: $NULLPLATFORM_API_KEY
NULLPLATFORM_ENCRIPTION_KEY: $NULLPLATFORM_ENCRIPTION_KEY
nullplatform-asset-lambda-build:
image: $[[ inputs.ci-image ]]
stage: nullplatform-asset-lambda-build
before_script:
- $[[ inputs.ci-before-script ]]
script:
- |+
# Sanitize function
sanitize_path() {
local path="$1"
# Remove "./" from the beginning of the path, but preserve "."
if [ "$path" != "./" ]; then
path="${path#./}"
fi
# Remove trailing slashes
path="${path%/}"
echo "$path"
}
# Sanitize paths
build_working_directory=$(sanitize_path "$[[ inputs.build-working-directory ]]")
asset_working_directory=$(sanitize_path "$[[ inputs.asset-working-directory ]]")
asset_output_directory=$(sanitize_path "$[[ inputs.asset-output-directory ]]")
- |+
#build
BUILD_WORKING_DIRECTORY=$build_working_directory
ASSET_WORKING_DIRECTORY=$asset_working_directory
ASSET_OUTPUT_DIRECTORY="$asset_working_directory/$asset_output_directory"
ASSET_NAME=$[[ inputs.asset-name ]]
ASSET_TYPE=lambda
if [ "$[[ inputs.command ]]" != "make" ]; then
echo "different of make"
else
make_file_path="$build_working_directory"
make_file_task="build"
build_command="make -C $make_file_path"
if [ "$[[ inputs.arguments ]]" != "build" ]; then
build_command="$build_command $[[ inputs.arguments ]]"
else
build_command="$build_command $make_file_task"
fi
if [ -n "$[[ inputs.options ]]" ]; then
build_command="$build_command $[[ inputs.options ]]"
fi
eval $build_command \
BUILD_WORKING_DIRECTORY=$BUILD_WORKING_DIRECTORY \
ASSET_WORKING_DIRECTORY=$ASSET_WORKING_DIRECTORY \
ASSET_OUTPUT_DIRECTORY=$ASSET_OUTPUT_DIRECTORY \
ASSET_NAME=$ASSET_NAME \
ASSET_TYPE=$ASSET_TYPE
fi
artifacts:
paths:
- "$[[ inputs.asset-working-directory ]]/$[[ inputs.asset-output-directory ]]"
expire_in: 30 min
except:
- tags