Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/workflows/ci-server.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
name: ci-server


on:
on:
workflow_call:
workflow_dispatch:
push:
paths:
- 'server/**'
- '.github/workflows/ci-server.yaml'
pull_request:
paths:
- 'server/**'
- '.github/workflows/ci-server.yaml'

jobs:
build:
Expand All @@ -31,9 +34,10 @@ jobs:
go build -v ./...

- name: Lint
uses: golangci/golangci-lint-action@v4
uses: golangci/golangci-lint-action@v6
with:
version: v1.63.4
version: v1.64.8
install-mode: goinstall
working-directory: ./server

- name: Unit test
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-bot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ jobs:
image_name: 'dishdash-bot'
environment: ${{ github.event.inputs.environment }}
secret-service-hash: ${{ github.event.inputs.environment == 'PROD' && 'BOT_SERVICE_HASH' || 'BOT_SERVICE_HASH_DEV' }}
push_to_ghcr: true
1 change: 1 addition & 0 deletions .github/workflows/deploy-miniapp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ jobs:
image_name: 'dishdash-miniapp'
environment: ${{ github.event.inputs.environment }}
secret-service-hash: ${{ github.event.inputs.environment == 'PROD' && 'MINIAPP_SERVICE_HASH' || 'MINIAPP_SERVICE_HASH_DEV' }}
push_to_ghcr: true
1 change: 1 addition & 0 deletions .github/workflows/deploy-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ jobs:
image_name: 'dishdash-backend'
environment: ${{ github.event.inputs.environment }}
secret-service-hash: ${{ github.event.inputs.environment == 'PROD' && 'SERVER_SERVICE_HASH' || 'SERVER_SERVICE_HASH_DEV' }}
push_to_ghcr: true
1 change: 1 addition & 0 deletions .github/workflows/deploy-storybook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ jobs:
image_name: 'dishdash-storybook'
environment: ${{ github.event.inputs.environment }}
secret-service-hash: ${{ github.event.inputs.environment == 'PROD' && 'STORYBOOK_SERVICE_HASH' || 'STORYBOOK_SERVICE_HASH_DEV' }}
push_to_ghcr: true
37 changes: 37 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ on:
required: true
description: name of secret value
type: string
push_to_ghcr:
required: false
type: boolean
default: false
description: also publish to ghcr.io with main-<sha>-<ts> tag for Flux ImagePolicy
ghcr_image_name:
required: false
type: string
default: ""
description: name of image on ghcr (defaults to image_name)

jobs:
push_to_registry:
Expand All @@ -51,23 +61,48 @@ jobs:
run: |
calculatedSha=$(git rev-parse --short ${{ github.sha }})
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
echo "BUILD_TS=$(date +%s)" >> $GITHUB_ENV

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Log in to GHCR
if: inputs.push_to_ghcr
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Define Docker tags
run: |
if [ "${{ inputs.environment }}" == "DEV" ]; then
echo "VERSION_TAG=dev" >> $GITHUB_ENV
elif [ "${{ inputs.environment }}" == "PROD" ]; then
echo "VERSION_TAG=latest" >> $GITHUB_ENV
fi
GHCR_NAME="${{ inputs.ghcr_image_name }}"
if [ -z "$GHCR_NAME" ]; then GHCR_NAME="${{ inputs.image_name }}"; fi
REPO_OWNER_LC="$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')"
echo "GHCR_REPO=ghcr.io/$REPO_OWNER_LC/$GHCR_NAME" >> $GITHUB_ENV

- name: Build and push Docker image
id: push
if: ${{ !inputs.push_to_ghcr }}
uses: docker/build-push-action@v5
with:
context: ./${{ inputs.context_path }}
file: ./${{ inputs.dockerfile_path }}/Dockerfile
push: true
tags: |
${{ secrets.DOCKER_USERNAME }}/${{ inputs.image_name }}:${{ env.VERSION_TAG }}
${{ secrets.DOCKER_USERNAME }}/${{ inputs.image_name }}:${{ env.COMMIT_SHORT_SHA }}

- name: Build and push to Docker Hub + GHCR
if: inputs.push_to_ghcr
uses: docker/build-push-action@v5
with:
context: ./${{ inputs.context_path }}
Expand All @@ -76,6 +111,8 @@ jobs:
tags: |
${{ secrets.DOCKER_USERNAME }}/${{ inputs.image_name }}:${{ env.VERSION_TAG }}
${{ secrets.DOCKER_USERNAME }}/${{ inputs.image_name }}:${{ env.COMMIT_SHORT_SHA }}
${{ env.GHCR_REPO }}:${{ env.VERSION_TAG }}
${{ env.GHCR_REPO }}:main-${{ env.COMMIT_SHORT_SHA }}-${{ env.BUILD_TS }}

- name: Docker hub push notification
uses: containrrr/shoutrrr-action@v1
Expand Down
4 changes: 3 additions & 1 deletion dashboard/cmd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Config struct {
Host string `envconfig:"POSTGRES_HOST"`
Port uint16 `envconfig:"POSTGRES_PORT"`
Database string `envconfig:"POSTGRES_DB"`
SSLMode string `default:"disable" envconfig:"POSTGRES_SSLMODE"`
}
Auth struct {
ApiToken string `envconfig:"API_TOKEN"`
Expand Down Expand Up @@ -68,12 +69,13 @@ func Print() {

func (c Config) DBUrl() string {
return fmt.Sprintf(
"postgres://%s:%s@%s:%d/%s?sslmode=disable",
"postgres://%s:%s@%s:%d/%s?sslmode=%s",
C.DB.User,
C.DB.Password,
C.DB.Host,
C.DB.Port,
C.DB.Database,
C.DB.SSLMode,
)
}

Expand Down
4 changes: 3 additions & 1 deletion server/cmd/server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Config struct {
Host string `envconfig:"POSTGRES_HOST"`
Port uint16 `envconfig:"POSTGRES_PORT"`
Database string `envconfig:"POSTGRES_DB"`
SSLMode string `default:"disable" envconfig:"POSTGRES_SSLMODE"`
AutoMigrate bool `envconfig:"POSTGRES_AUTOMIGRATE"`
}
Defaults struct {
Expand Down Expand Up @@ -74,12 +75,13 @@ func Print() {

func (c Config) DBUrl() string {
return fmt.Sprintf(
"postgres://%s:%s@%s:%d/%s?sslmode=disable",
"postgres://%s:%s@%s:%d/%s?sslmode=%s",
C.DB.User,
C.DB.Password,
C.DB.Host,
C.DB.Port,
C.DB.Database,
C.DB.SSLMode,
)
}

Expand Down
Loading