Skip to content

Commit

Permalink
fix the deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottminns committed Nov 12, 2024
1 parent 0b1e0f0 commit 104ed39
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 11 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,56 @@ on:
branches:
- deploytest

permissions:
packages: write

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22.x'
- name: Install dependencies
run: go get .
- name: Build
run: go build -v ./...
- name: Test with the Go CLI
run: go test

build-and-push-image:
needs: build-and-test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set short git commit SHA
id: vars
run: |
calculatedSha=$(git rev-parse --short ${{ github.sha }})
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: https://ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ghcr.io/dreamsofcode-io/guestbook:$COMMIT_SHORT_SHA

deploy:
runs-on: ubuntu-latest
needs: build-and-push-image

steps:
- name: Checkout code
Expand All @@ -34,6 +81,7 @@ jobs:
- name: Run Docker Compose
run: |
export GIT_COMMIT_HASH=$COMMIT_SHORT_SHA
export DB_PASSWORD_PATH="/home/deploytest/db-password.txt"
export DOCKER_HOST=ssh://[email protected]
docker-compose -f ./compose.prod.yaml up -d
12 changes: 1 addition & 11 deletions compose.prod.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
services:
watchtower:
image: containrrr/watchtower
command:
- "--label-enable"
- "--interval"
- "30"
- "--rolling-restart"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
reverse-proxy:
image: traefik:v3.1
command:
Expand All @@ -27,7 +18,7 @@ services:
- letsencrypt:/letsencrypt
- /var/run/docker.sock:/var/run/docker.sock
guestbook:
image: ghcr.io/dreamsofcode-io/guestbook:prod
image: ghcr.io/dreamsofcode-io/guestbook:${GIT_COMMIT_HASH:-prod}
labels:
- "traefik.enable=true"
- "traefik.http.middlewares.guestbook-ratelimit.ratelimit.average=20"
Expand Down Expand Up @@ -75,7 +66,6 @@ services:
environment:
- POSTGRES_DB=guestbook
- POSTGRES_PASSWORD_FILE=/run/secrets/db-password
#- POSTGRES_PASSWORD=${DB_PASSWORD}
expose:
- 5432
healthcheck:
Expand Down

0 comments on commit 104ed39

Please sign in to comment.