-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
55 lines (44 loc) · 1.99 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
.PHONY: all
all: gitbackup
# Change this if you lack access to either of these Keybase repositories:
BACKUP_NAMESPACES = wwp wwp-test
.PHONY: checkout
checkout:
$(MAKE) k8s-backup/wwp-test || true
$(MAKE) k8s-backup/wwp || true
k8s-backup/wwp-test:
mkdir k8s-backup || true
cd k8s-backup && git clone keybase://team/epfl_wp_test/k8s-backup wwp-test
k8s-backup/wwp:
mkdir k8s-backup || true
cd k8s-backup && git clone keybase://team/epfl_wp_prod/k8s-backup wwp
_BACKUP_REPOS = $(patsubst %, k8s-backup/%, $(BACKUP_NAMESPACES))
_BACKUP_YAMLS = $(patsubst %, %/configmaps.yaml, $(_BACKUP_REPOS))
COMMIT_MSG = "Automatic commit"
.PHONY: gitbackup
gitbackup: $(_BACKUP_YAMLS)
set -e -x; \
for keybase_repo in $(_BACKUP_REPOS); do \
(cd $$keybase_repo; \
git fetch; git reset --hard origin/master; \
oc get -o yaml -n "`basename "$$keybase_repo"`" configmaps > configmaps.yaml; \
oc get -o yaml -n "`basename "$$keybase_repo"`" routes > routes.yaml; \
git add *.yaml; \
git commit -m "`echo "$(COMMIT_MSG)\n\nmade with $(MAKE)"`" *.yaml || true; \
git push); \
done
S3_ENDPOINT_URL=https://s3.epfl.ch/
S3_ASSETS_BUCKET=svc0041-c1561ba80625465c2a53f01693922e7c
define source_assets_secrets
. /keybase/team/epfl_wp_test/s3-assets-credentials.sh; \
export AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_DEFAULT_REGION
endef
.PHONY: assets
assets:
@-mkdir assets 2>/dev/null || true
$(source_assets_secrets); \
aws --endpoint-url=$(S3_ENDPOINT_URL) s3 sync s3://$(S3_ASSETS_BUCKET) assets/
.PHONY: push-assets
push-assets:
$(source_assets_secrets); \
aws --endpoint-url=$(S3_ENDPOINT_URL) s3 sync assets/ s3://$(S3_ASSETS_BUCKET)