-
Notifications
You must be signed in to change notification settings - Fork 1
/
.razorops.yaml
44 lines (37 loc) · 1.59 KB
/
.razorops.yaml
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
global:
variables:
- AWS_REGION=ap-southeast-1
- DRONE_LAMBDA_VERSION=1.3.7
tasks:
deploy:
steps:
- checkout
- commands:
- echo "Changed files in $CI_COMMIT_SHA"
- git diff-tree --no-commit-id --name-only $CI_COMMIT_SHA -r
- |
echo "Downloading drone-lambda $DRONE_LAMBDA_VERSION ..."
curl -sSLO https://github.com/appleboy/drone-lambda/releases/download/v$DRONE_LAMBDA_VERSION/drone-lambda-$DRONE_LAMBDA_VERSION-linux-amd64
mv drone-lambda-$DRONE_LAMBDA_VERSION-linux-amd64 drone-lambda
mv drone-lambda ~/bin/drone-lambda && chmod +x ~/bin/drone-lambda
drone-lambda --version
- if: branch == "main"
run: |
MODIFIED_FOLDERS=$(git diff-tree --no-commit-id --name-only $CI_COMMIT_SHA | xargs)
FOLDERS=("python-1" "python-2")
FUNCTIONS=("demo-py1" "demo-py2")
for index in "${!FOLDERS[@]}"; do
funcPath="${FOLDERS[$index]}"
funcName="${FUNCTIONS[$index]}"
test -n "$funcPath"
test -n "$funcName"
if [[ "$MODIFIED_FOLDERS" =~ "$funcPath" ]]; then
echo "\t Detected changes in $funcPath, deploying code on Lambda $funcName"
pushd $funcPath && \
pip3 install -r requirements.txt -t . && \
zip -r code-$funcName-$CI_COMMIT_SHA.zip . -x \*.pyc *.git* && \
drone-lambda --function-name=$funcName --zip-file code-$funcName-$CI_COMMIT_SHA.zip --commit.sha ${CI_COMMIT_SHA:0:8} --publish true && \
popd
echo "Deployed $funcPath on Lambda $funcName"
fi
done