Skip to content

fix(consumption): display correct year labels for annual curve #84

fix(consumption): display correct year labels for annual curve

fix(consumption): display correct year labels for annual curve #84

Workflow file for this run

name: Build and Push Docker Images
on:
push:
tags:
- 'v*'
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
inputs:
version:
description: 'Version tag (e.g., 1.0.0). Leave empty for "dev-{sha}"'
required: false
default: ''
env:
REGISTRY: ghcr.io
IMAGE_PREFIX: ghcr.io/myelectricaldata/myelectricaldata_new
jobs:
# Prepare version info (shared by all build jobs)
prepare:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Get version
id: version
run: |
if [ -n "${{ github.event.inputs.version }}" ]; then
# Manual input: use as-is
VERSION="${{ github.event.inputs.version }}"
elif [[ "${{ github.ref }}" == refs/tags/v* ]]; then
# Version tag: strip 'v' prefix
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#v}"
else
# Branch push (main): use dev-{short_sha}
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
VERSION="dev-${SHORT_SHA}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
# Build images in parallel using matrix strategy
build:
needs: prepare
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
include:
- image: backend
context: ./apps/api
- image: frontend
context: ./apps/web
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: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push ${{ matrix.image }}
uses: docker/build-push-action@v6
with:
context: ${{ matrix.context }}
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ env.IMAGE_PREFIX }}/${{ matrix.image }}:${{ needs.prepare.outputs.version }}
${{ env.IMAGE_PREFIX }}/${{ matrix.image }}:latest
cache-from: type=gha,scope=${{ matrix.image }}
cache-to: type=gha,mode=max,scope=${{ matrix.image }}
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
# Summary job (runs after all builds complete)
summary:
needs: [prepare, build]
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- name: Create summary
run: |
echo "## Docker Images Published 🐳" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Images" >> $GITHUB_STEP_SUMMARY
echo "| Image | Tag | Architectures |" >> $GITHUB_STEP_SUMMARY
echo "|-------|-----|---------------|" >> $GITHUB_STEP_SUMMARY
echo "| \`${{ env.IMAGE_PREFIX }}/backend\` | \`${{ needs.prepare.outputs.version }}\` | amd64, arm64 |" >> $GITHUB_STEP_SUMMARY
echo "| \`${{ env.IMAGE_PREFIX }}/frontend\` | \`${{ needs.prepare.outputs.version }}\` | amd64, arm64 |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Pull Commands" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
echo "docker pull ${{ env.IMAGE_PREFIX }}/backend:${{ needs.prepare.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "docker pull ${{ env.IMAGE_PREFIX }}/frontend:${{ needs.prepare.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY