Skip to content

Merge pull request #63 from zwaetschge/claude/fix-note-gradient-trans… #54

Merge pull request #63 from zwaetschge/claude/fix-note-gradient-trans…

Merge pull request #63 from zwaetschge/claude/fix-note-gradient-trans… #54

Workflow file for this run

name: Docker Build and Push
on:
push:
branches:
- main
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
version:
description: 'Version tag (e.g., v1.0.0)'
required: false
default: 'latest'
env:
REGISTRY: docker.io
IMAGE_NAME: keeplocal
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable={{is_default_branch}}
type=sha,prefix={{date 'YYYY-MM-DD'}}-
- name: Build and push All-in-One Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.allinone
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Update Docker Hub description
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}
short-description: "KeepLocal - Self-hosted Google Keep alternative"
readme-filepath: ./README.md
test-image:
needs: build-and-push
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Generate JWT Secret
id: jwt
run: echo "secret=$(openssl rand -base64 32)" >> $GITHUB_OUTPUT
- name: Pull and test Docker image
run: |
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
docker run -d \
--name keeplocal-test \
-p 3000:80 \
-e JWT_SECRET="${{ steps.jwt.outputs.secret }}" \
-e ALLOWED_ORIGINS="http://localhost:3000" \
-e NODE_ENV="production" \
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
- name: Wait for services to start
run: |
echo "Waiting for services to start..."
sleep 45
- name: Check container logs
run: |
echo "=== Container Logs ==="
docker logs keeplocal-test
- name: Test health endpoint
run: |
echo "Testing health endpoint..."
max_attempts=10
attempt=0
while [ $attempt -lt $max_attempts ]; do
if curl -f http://localhost:3000/api/health; then
echo "Health check passed!"
exit 0
fi
attempt=$((attempt + 1))
echo "Attempt $attempt/$max_attempts failed, retrying in 5s..."
sleep 5
done
echo "Health check failed after $max_attempts attempts"
docker logs keeplocal-test
exit 1
- name: Test WebUI
run: |
echo "Testing WebUI..."
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:3000/)
if [ "$HTTP_CODE" = "200" ]; then
echo "WebUI accessible (HTTP $HTTP_CODE)"
else
echo "WebUI not accessible (HTTP $HTTP_CODE)"
docker logs keeplocal-test
exit 1
fi
- name: Cleanup
if: always()
run: |
docker stop keeplocal-test || true
docker rm keeplocal-test || true