-
Notifications
You must be signed in to change notification settings - Fork 2
/
buildspec.release-lambda.yml
64 lines (55 loc) · 2.76 KB
/
buildspec.release-lambda.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
version: 0.2
phases:
install:
runtime-versions:
nodejs: 20
build:
commands:
- npm i -g pnpm
- pnpm install
- node scripts/downloadGithubRelease.mjs
- unzip package.zip -d dist
- cd dist
- zip -r latest.zip fingerprintjs-pro-cloudfront-lambda-function.js
- zip -r latest_mgmt.zip fingerprintjs-pro-cloudfront-mgmt-lambda-function.js
- aws s3api get-object --bucket fingerprint-pro-cloudfront-integration --key v2/lambda_latest.zip previous.zip
- aws s3api get-object --bucket fingerprint-pro-cloudfront-integration --key v2/mgmt_lambda_latest.zip previous_mgmt.zip
- aws s3api get-object --bucket fingerprint-pro-cloudfront-integration --key v2/template.yml previous-template.yml
- unzip previous.zip -d previous
- unzip previous_mgmt.zip -d previous_mgmt
- diff previous/fingerprintjs-pro-cloudfront-lambda-function.js fingerprintjs-pro-cloudfront-lambda-function.js; diffStatus=$?
- diff previous_mgmt/fingerprintjs-pro-cloudfront-mgmt-lambda-function.js fingerprintjs-pro-cloudfront-mgmt-lambda-function.js; mgmtDiffStatus=$?
- diff previous-template.yml template.yml; templateDiffStatus=$?
- echo $diffStatus
- echo $mgmtDiffStatus
- echo $templateDiffStatus
- echo "Processing fingerprintjs-pro-cloudfront-lambda-function.js"
- >-
if [ $diffStatus -eq 0 ]; then
echo "Files are the same. Don't need to upload the file."
elif [ $diffStatus -eq 1 ]; then
echo "Files are different. Uploading new version."
aws s3api put-object --body latest.zip --bucket fingerprint-pro-cloudfront-integration --key v2/lambda_latest.zip
else
echo "There was something wrong with the diff command."
fi
- echo "Processing fingerprintjs-pro-cloudfront-mgmt-lambda-function.js"
- >-
if [ $mgmtDiffStatus -eq 0 ]; then
echo "Files are the same. Don't need to upload the file."
elif [ $mgmtDiffStatus -eq 1 ]; then
echo "Files are different. Uploading new version."
aws s3api put-object --body latest_mgmt.zip --bucket fingerprint-pro-cloudfront-integration --key v2/mgmt_lambda_latest.zip
else
echo "There was something wrong with the diff command."
fi
- echo "Processing template.yml"
- >-
if [ $templateDiffStatus -eq 0 ]; then
echo "Files are the same. Don't need to upload the file."
elif [ $templateDiffStatus -eq 1 ]; then
echo "Files are different. Uploading new version."
aws s3api put-object --body template.yml --bucket fingerprint-pro-cloudfront-integration --key v2/template.yml
else
echo "There was something wrong with the diff command."
fi