-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
58 lines (41 loc) · 1.45 KB
/
Makefile
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
SHELL := /bin/bash
.PHONY: dependencies api clean fresh deploy
export NODE_OPTIONS := --max-old-space-size=8192
dependencies:
bash -c 'yarn install'
clean:
rm -rf node_modules
rm -rf yarn.lock
rm -rf package-lock.json
fresh: clean dependencies
download: /tmp/aws_ec2_services.json /tmp/aws_ec2_products.jsonl /tmp/aws_ec2_terms.json
#
# Services
#
/tmp/aws_ec2_services.json:
@echo Downloading AWS Offers file.
curl -Ls https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/index.json > /tmp/aws_ec2_services.json
#
# Products
#
/tmp/aws_ec2_products.json: /tmp/aws_ec2_services.json
@echo Generating Products File
cat /tmp/aws_ec2_services.json | npx JSONStream 'products.*' > /tmp/aws_ec2_products.json
/tmp/aws_ec2_products.jsonl: /tmp/aws_ec2_products.json
@echo Converting products.json to jsonl
cat /tmp/aws_ec2_products.json | jq -cn --stream 'fromstream(1|truncate_stream(inputs))' > /tmp/aws_ec2_products.jsonl
#
# Terms
#
/tmp/aws_ec2_terms.json: /tmp/aws_ec2_services.json
@echo Generating Terms File
cat /tmp/aws_ec2_services.json | npx JSONStream 'terms.OnDemand.*' > /tmp/aws_ec2_terms.json
#
# Actual stuff
#
api:
node --max-old-space-size=4096 ./bin/instance_details.js yaml > ./api/ec2instances.yaml
node --max-old-space-size=4096 ./bin/instance_details.js json > ./api/ec2instances.json
deploy: download api
git add api/*
git diff --quiet HEAD api/ || git commit -m "Automated API update from CircleCI"; git push