File tree Expand file tree Collapse file tree 2 files changed +46
-11
lines changed Expand file tree Collapse file tree 2 files changed +46
-11
lines changed Original file line number Diff line number Diff line change 5
5
branches :
6
6
- deploytest
7
7
8
+ permissions :
9
+ packages : write
10
+
8
11
jobs :
12
+ build-and-test :
13
+ runs-on : ubuntu-latest
14
+
15
+ steps :
16
+ - uses : actions/checkout@v4
17
+ - name : Setup Go
18
+ uses : actions/setup-go@v5
19
+ with :
20
+ go-version : ' 1.22.x'
21
+ - name : Install dependencies
22
+ run : go get .
23
+ - name : Build
24
+ run : go build -v ./...
25
+ - name : Test with the Go CLI
26
+ run : go test
27
+
28
+ build-and-push-image :
29
+ runs-on : ubuntu-latest
30
+ steps :
31
+ - name : Checkout repository
32
+ uses : actions/checkout@v3
33
+
34
+ - name : Set short git commit SHA
35
+ id : vars
36
+ run : |
37
+ calculatedSha=$(git rev-parse --short ${{ github.sha }})
38
+ echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
39
+
40
+ - name : Log in to the Container registry
41
+ uses : docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
42
+ with :
43
+ registry : https://ghcr.io
44
+ username : ${{ github.actor }}
45
+ password : ${{ secrets.GITHUB_TOKEN }}
46
+
47
+ - name : Build and push Docker image
48
+ uses : docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
49
+ with :
50
+ context : .
51
+ push : true
52
+ tags : ghcr.io/dreamsofcode-io/guestbook:$COMMIT_SHORT_SHA
9
53
deploy :
10
54
runs-on : ubuntu-latest
11
55
34
78
35
79
- name : Run Docker Compose
36
80
run : |
81
+ export GIT_COMMIT_HASH=$COMMIT_SHORT_SHA
37
82
export DB_PASSWORD_PATH="/home/deploytest/db-password.txt"
38
83
export DOCKER_HOST=ssh://[email protected]
39
84
docker-compose -f ./compose.prod.yaml up -d
Original file line number Diff line number Diff line change 1
1
services :
2
- watchtower :
3
- image : containrrr/watchtower
4
- command :
5
- - " --label-enable"
6
- - " --interval"
7
- - " 30"
8
- - " --rolling-restart"
9
- volumes :
10
- - /var/run/docker.sock:/var/run/docker.sock
11
2
reverse-proxy :
12
3
image : traefik:v3.1
13
4
command :
@@ -27,7 +18,7 @@ services:
27
18
- letsencrypt:/letsencrypt
28
19
- /var/run/docker.sock:/var/run/docker.sock
29
20
guestbook :
30
- image : ghcr.io/dreamsofcode-io/guestbook:prod
21
+ image : ghcr.io/dreamsofcode-io/guestbook:${GIT_COMMIT_HASH:- prod}
31
22
labels :
32
23
- " traefik.enable=true"
33
24
- " traefik.http.middlewares.guestbook-ratelimit.ratelimit.average=20"
@@ -75,7 +66,6 @@ services:
75
66
environment :
76
67
- POSTGRES_DB=guestbook
77
68
- POSTGRES_PASSWORD_FILE=/run/secrets/db-password
78
- # - POSTGRES_PASSWORD=${DB_PASSWORD}
79
69
expose :
80
70
- 5432
81
71
healthcheck :
You can’t perform that action at this time.
0 commit comments