-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
81 lines (60 loc) · 1.87 KB
/
Makefile
File metadata and controls
81 lines (60 loc) · 1.87 KB
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
SOPS_FILES := $(shell find vault -name '*.enc')
encrypt:
@for file in $(shell find vault -type f \
! -name '*.enc' \
! -name '.stow-local-ignore' \
! -name '.DS_Store' \
! -name '*.bak' \
! -name '.gitignore'); do \
echo "Encrypting $$file -> $$file.enc"; \
SOPS_AGE_KEY="AGE-SECRET-KEY-DUMMY" \
sops --encrypt --output $$file.enc $$file; \
done
# only decrypt files that are newer than the decrypted version
decrypt:
@SOPS_AGE_KEY=$$(op read "op://Private/dotfiles-sops-age-private-key/secret" --account my.1password.com); \
for encfile in $(SOPS_FILES); do \
plainfile=$$(echo $$encfile | sed 's/\.enc$$//'); \
if [ ! -f $$plainfile ] || [ $$encfile -nt $$plainfile ]; then \
if [ -f $$plainfile ]; then \
backupfile=$${plainfile}.$$(date +%Y%m%d%H%M%S).bak; \
echo "Backing up existing $$plainfile to $$backupfile"; \
cp $$plainfile $$backupfile; \
fi; \
echo "Decrypting $$encfile -> $$plainfile"; \
SOPS_AGE_KEY=$$SOPS_AGE_KEY sops --decrypt --output $$plainfile $$encfile; \
else \
echo "Skipping $$encfile (up to date)"; \
fi \
done
stow-core:
stow --target=$(HOME) core
stow-vault:
stow --target=$(HOME) vault
install: decrypt stow-core stow-vault
stage: encrypt
@echo "Staging files..."
@git add .
commit: stage
@read -p "Commit message: " msg; \
git commit -m "$$msg"
push:
git push origin main
sync: commit push
.PHONY: encrypt decrypt stow-core stow-vault install stage commit push sync
# IMAGE_PREFIX = maruftuhin
# IMAGE_REPO = dotfiles
# IMAGE_VERSION ?= latest
# IMAGE_NAME = $(IMAGE_PREFIX)/$(IMAGE_REPO):$(IMAGE_VERSION)
# .PHONY: build push run install
# build:
# docker build -t $(IMAGE_NAME) .
# push:
# docker push $(IMAGE_NAME)
# run:
# docker run -ti --rm $(IMAGE_NAME)
# kube-run:
# kubectl run -i -t --image=$(IMAGE_NAME) shell --restart=Never --rm
# install:
# ./bin/dotfiles
# default: build