aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorey Prophitt <git@prophitt.me>2022-07-26 16:12:14 -0700
committerCorey Prophitt <git@prophitt.me>2022-07-26 16:12:14 -0700
commit52dcf92dab36ff60ce0658c31953bb9a81345aa2 (patch)
treebff91d31144b528ac545e18c17ad4c2bf7b6ed5d
parent35cb3c5f44ad885a6410a5038156016178bb31e3 (diff)
downloadprophitt.me-52dcf92dab36ff60ce0658c31953bb9a81345aa2.tar.gz
prophitt.me-52dcf92dab36ff60ce0658c31953bb9a81345aa2.zip
Added deploy task and githooks for development
-rw-r--r--Makefile14
-rw-r--r--config/development/githooks/pre-commit.sh19
-rwxr-xr-xconfig/development/githooks/pre-push.sh30
3 files changed, 62 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 158e0d6..16fa80f 100644
--- a/Makefile
+++ b/Makefile
@@ -11,4 +11,16 @@ ifdef GOSEC
11 gosec -color -quiet ./... 11 gosec -color -quiet ./...
12endif 12endif
13 13
14.PHONY: run test 14dev:
15 cp config/development/githooks/pre-commit.sh .git/hooks/pre-commit
16 chmod +x .git/hooks/pre-commit
17 cp config/development/githooks/pre-push.sh .git/hooks/pre-push
18 chmod +x .git/hooks/pre-push
19
20deploy:
21 @rm -rf /tmp/prophitt-production
22 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o /tmp/prophitt-production ./cmd/prophitt/main.go
23 rsync -vaP --exclude=.gitkeep --exclude=.env /tmp/prophitt-production root@prophitt.me:/deploy/prophitt.me/prophitt-production
24 ssh root@prophitt.me -C "bash -c '/deploy/prophitt.me/scripts/deploy.sh'"
25
26.PHONY: run test dev deploy
diff --git a/config/development/githooks/pre-commit.sh b/config/development/githooks/pre-commit.sh
new file mode 100644
index 0000000..60c0a9d
--- /dev/null
+++ b/config/development/githooks/pre-commit.sh
@@ -0,0 +1,19 @@
1#!/usr/bin/bash
2
3# Blacklisted words.
4LIST="DEBUG|TEST|DEV"
5
6if git rev-parse --verify HEAD >/dev/null 2>&1; then
7 against=HEAD
8else
9 against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
10fi
11
12for FILE in `git diff-index --name-status --cached $against -- | cut -c3-` ; do
13 if grep -E $LIST $FILE; then
14 echo $FILE." has one of the word you don't want to commit. Please remove it"
15 exit 1
16 fi
17done
18
19exit
diff --git a/config/development/githooks/pre-push.sh b/config/development/githooks/pre-push.sh
new file mode 100755
index 0000000..821c7af
--- /dev/null
+++ b/config/development/githooks/pre-push.sh
@@ -0,0 +1,30 @@
1#!/usr/bin/bash
2
3# Copy this file to .git/hooks
4
5echo "Running Tests"
6
7go test ./...
8
9test=$?
10
11if [ $test -eq 0 ]; then
12 echo "Code looks good, time to test!"
13else
14 echo "Cannot push, code linting failed. Use --no-verify to force push."
15 exit 1
16fi
17
18echo "Running Security Checker"
19
20gosec -color -quiet ./...
21
22test=$?
23
24if [ $test -eq 0 ]; then
25 echo "Tests are green, pushing..."
26 exit 0
27else
28 echo "Cannot push, tests are failing. Use --no-verify to force push."
29 exit 1
30fi