-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd.sh
executable file
·30 lines (25 loc) · 882 Bytes
/
cmd.sh
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
#!/bin/sh
########################################
# Required env vars:
# * GIT_USER_NAME
# * GIT_USER_EMAIL
# * GIT_PRIVATE_KEY
# * GIT_REPO_HOST
# * GIT_REPO_URL
# * LEDGER_FILE_NAME
# * GETMAIL_PW
########################################
mkdir ~/.ssh
printf '%s\n' "$GIT_PRIVATE_KEY" > ~/.ssh/id_rsa
ssh-keyscan -t rsa $GIT_REPO_HOST >> ~/.ssh/known_hosts
chmod -R 700 ~/.ssh
git config --global user.name $GIT_USER_NAME
git config --global user.email $GIT_USER_EMAIL
git clone $GIT_REPO_URL accounting
export LEDGER_FILE="/home/hledger/accounting/$LEDGER_FILE_NAME"
echo $GETMAIL_PW > /tmp/getmailpw
mkdir -p ~/accounting/email_importer/mail/new ~/accounting/email_importer/mail/cur ~/accounting/email_importer/mail/tmp
cd ~/accounting
set -o pipefail
./email_importer/app/main.py &&
(git add . && git commit -m "Email alerts import $(date -Iseconds)" && git push) || true