-
Notifications
You must be signed in to change notification settings - Fork 3
/
run.sh
executable file
·51 lines (38 loc) · 1.09 KB
/
run.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
#
# script to run on localhost
#
set -o errexit
set -o pipefail
set -o nounset
echo "INFO: starting at $(date -u +%Y-%m-%dT%H:%M:%SZ)"
if [ ! -d "./dist" ]; then
echo "INFO: creating dist directory"
mkdir ./dist
fi
if [ -f "./dist/ghashboard" ]; then
echo "INFO: removing old build of ghashboard"
rm ./dist/ghashboard
fi
COMMIT=$(git rev-parse HEAD)-local
LASTMOD=$(date -u +%Y-%m-%dT%H:%M:%SZ)
VERSION=local
BUILTBY=run.sh
echo "INFO: building new ghashboard"
go build \
-ldflags "-X main.commit=$COMMIT -X main.date=$LASTMOD -X main.version=$VERSION -X main.builtBy=$BUILTBY -extldflags '-static'" \
-o ./dist/ghashboard \
./*.go
if [ ! -f "./dist/ghashboard" ]; then
echo "ERROR: failed to build ghashboard"
exit 1
fi
echo "INFO: running $(./dist/ghashboard --version)"
if [ -f ".env" ]; then
echo "INFO: loading environment variables from .env"
export $(grep -v '^#' .env)
fi
export GITHUB_TOKEN=$(gh auth token)
echo "INFO: running ghashboard with arguments: $@"
./dist/ghashboard "$@"
echo "INFO: complete at $(date -u +%Y-%m-%dT%H:%M:%SZ)"