Skip to content

feat: add StatsPage with collection valuation charts and integrate in… #143

feat: add StatsPage with collection valuation charts and integrate in…

feat: add StatsPage with collection valuation charts and integrate in… #143

name: Build and Push Docker Images
on:
# Build on push to develop branch (nightly/unstable builds)
# Also trigger on version tags (v1.0.0) for production deployments
push:
branches: ['develop']
tags: ['v*']
# Build on PR to validate changes (no push)
pull_request:
branches: ['main', 'develop']
# Manual trigger for testing
workflow_dispatch:
inputs:
platforms:
description: 'Target platforms (comma-separated)'
required: false
default: 'linux/amd64'
type: string
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
create-release:
name: Create GitHub Release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Extract Release Notes
id: extract_notes
run: |
VERSION=${GITHUB_REF#refs/tags/v}
# Extract the section for this version from the public changelog
awk "/^## \\\[$VERSION\\\]/{flag=1; next} /^## \\\[/{if(flag) exit} flag" frontend/public/CHANGELOG.md > release_notes.md
echo "notes_file=release_notes.md" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v2
with:
body_path: ${{ steps.extract_notes.outputs.notes_file }}
generate_release_notes: false
build-and-push:
name: Build Docker Images
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- context: ./backend
image: backend
- context: ./frontend
image: frontend
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Read VERSION file
id: version
run: echo "version=$(cat VERSION)" >> $GITHUB_OUTPUT
- name: Determine version type
id: version_type
run: |
VERSION="${{ steps.version.outputs.version }}"
if [[ "$VERSION" =~ -(beta|alpha|rc)\. ]]; then
echo "is_prerelease=true" >> $GITHUB_OUTPUT
echo "prerelease_type=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT
else
echo "is_prerelease=false" >> $GITHUB_OUTPUT
echo "prerelease_type=" >> $GITHUB_OUTPUT
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.image }}
tags: |
# Branch-based tags
type=ref,event=branch
type=ref,event=pr
# Develop branch gets 'develop' and 'nightly' tags
type=raw,value=develop,enable=${{ github.ref == 'refs/heads/develop' }}
type=raw,value=nightly,enable=${{ github.ref == 'refs/heads/develop' }}
# Version tags for releases
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
# SHA for traceability
type=sha,prefix=sha-
# 'latest' tag only for stable releases (not prereleases)
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') && steps.version_type.outputs.is_prerelease == 'false' }}
# 'beta' tag for prerelease versions
type=raw,value=beta,enable=${{ startsWith(github.ref, 'refs/tags/v') && steps.version_type.outputs.is_prerelease == 'true' }}
# Explicit version tag from VERSION file
type=raw,value=${{ steps.version.outputs.version }},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ${{ matrix.context }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.version.outputs.version }}
COMMIT_SHA=${{ github.sha }}
BUILD_DATE=${{ github.event.head_commit.timestamp }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: ${{ inputs.platforms || 'linux/amd64' }}
- name: Image digest
run: echo ${{ steps.meta.outputs.digest }}
- name: Summary
run: |
echo "## 🐳 Docker Image Built" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Image:** \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.image }}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Tags:**" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY