Skip to content
Open
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
36 changes: 31 additions & 5 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#.dockerignore

node_modules
npm-debug.log
Dockerfile*
docker-compose*
.dockerignore
Expand All @@ -9,9 +8,36 @@ docker-compose*
README.md
LICENSE
.vscode
.devcontainer
Makefile
helm-charts
.env
helm-charts/
helm/
k8s/
.env*
.editorconfig
.idea
coverage*
coverage*
*.log
.cache
.DS_Store
Thumbs.db

# Source files not needed in container
bruno/
sample_data*.json
sample.env
seeds/
init-db/
*.md
fly.toml

# Development scripts
setup-dataviz.sh
*.sh

# Test files
test/
tests/
__tests__/
*.test.*
*.spec.*
198 changes: 188 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
name: release
name: πŸš€ Release

on:
push:
branches: [main]
branches: [main, k8s-ready]
tags:
- "v*"
pull_request:
branches: [main]
branches: [main, k8s-ready]

permissions:
# To push Docker images to GitHub
packages: write
# To push Helm charts to GitHub
contents: write
# To push commits and tags
actions: read

jobs:
docker-build:
name: 🐳 Build Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout
- name: πŸ“¦ Checkout
uses: actions/checkout@v4
- name: Docker meta

- name: 🏷️ Docker meta
id: meta
uses: docker/metadata-action@v5
with:
Expand All @@ -30,27 +36,199 @@ jobs:
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Set up QEMU

- name: πŸ”§ Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
- name: πŸ—οΈ Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64

- name: Login to GitHub Container Registry
- name: πŸ” Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
- name: πŸš€ Build and push
uses: docker/build-push-action@v6
with:
file: "Dockerfile.app"
file: "Dockerfile"
platforms: linux/amd64
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

helm-release:
name: βš“ Helm Chart Release
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/k8s-ready')
steps:
- name: πŸ“¦ Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: πŸ” Check for Helm chart changes (excluding values files)
uses: dorny/paths-filter@v3
id: changes
with:
filters: |
charts:
- 'charts/**'
- '!charts/**/values*.yaml'
- '!charts/**/values*.yml'

- name: βš“ Install Helm
if: steps.changes.outputs.charts == 'true'
uses: azure/setup-helm@v4
with:
version: '3.14.0'

- name: πŸ“¦ Update Helm dependencies
if: steps.changes.outputs.charts == 'true'
run: |
cd charts/dataviz-srv
helm dependency update

- name: 🏷️ Auto-version Helm chart
if: steps.changes.outputs.charts == 'true'
id: version
run: |
cd charts/dataviz-srv

# Get current version from Chart.yaml
CURRENT_VERSION=$(grep '^version:' Chart.yaml | awk '{print $2}' | tr -d '"')

# If no version exists, start with 1.0.0
if [ -z "$CURRENT_VERSION" ] || [ "$CURRENT_VERSION" = "null" ]; then
NEW_VERSION="1.0.0"
else
# Parse version components
IFS='.' read -r major minor patch <<< "$CURRENT_VERSION"

# Increment patch version
NEW_VERSION="$major.$minor.$((patch + 1))"
fi

echo "🏷️ Current chart version: $CURRENT_VERSION"
echo "🏷️ New chart version: $NEW_VERSION"

# Update Chart.yaml with new chart version
sed -i "s/^version:.*/version: \"$NEW_VERSION\"/" Chart.yaml

# Update appVersion only if this is a tag push (new app release)
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
# Extract version from tag (e.g., v1.2.3 -> 1.2.3)
APP_VERSION=${GITHUB_REF#refs/tags/}
APP_VERSION=${APP_VERSION#v} # Remove 'v' prefix if present

echo "πŸš€ This is a tag push, updating appVersion to: $APP_VERSION"
sed -i "s/^appVersion:.*/appVersion: \"$APP_VERSION\"/" Chart.yaml

echo "app_version=$APP_VERSION" >> $GITHUB_OUTPUT
else
echo "πŸ“ Branch push - keeping current appVersion unchanged"
CURRENT_APP_VERSION=$(grep '^appVersion:' Chart.yaml | awk '{print $2}' | tr -d '"')
echo "app_version=$CURRENT_APP_VERSION" >> $GITHUB_OUTPUT
fi

echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT

# Show the changes
echo "πŸ“ Updated Chart.yaml:"
cat Chart.yaml | grep -E '^(version|appVersion):'

- name: πŸ” Helm lint
if: steps.changes.outputs.charts == 'true'
run: |
helm lint charts/dataviz-srv

- name: βœ… Helm template validation
if: steps.changes.outputs.charts == 'true'
run: |
helm template dataviz-srv charts/dataviz-srv --values charts/dataviz-srv/values.yaml --dry-run

- name: πŸ“ Commit version bump
if: steps.changes.outputs.charts == 'true'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add charts/dataviz-srv/Chart.yaml

# Create appropriate commit message
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
git commit -m "🏷️ Bump Helm chart to ${{ steps.version.outputs.new_version }} + app to ${{ steps.version.outputs.app_version }}"
else
git commit -m "🏷️ Bump Helm chart version to ${{ steps.version.outputs.new_version }}"
fi

git push

- name: πŸ“¦ Package Helm chart
if: steps.changes.outputs.charts == 'true'
run: |
helm package charts/dataviz-srv

- name: πŸ” Login to GitHub Container Registry for Helm
if: steps.changes.outputs.charts == 'true'
run: |
echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io -u ${{ github.repository_owner }} --password-stdin

- name: πŸš€ Push Helm chart
if: steps.changes.outputs.charts == 'true'
run: |
helm push dataviz-srv-${{ steps.version.outputs.new_version }}.tgz oci://ghcr.io/teamdigitale/helm-charts

- name: 🏷️ Create Git tag
if: steps.changes.outputs.charts == 'true'
run: |
git tag "helm-v${{ steps.version.outputs.new_version }}"
git push origin "helm-v${{ steps.version.outputs.new_version }}"

helm-validation:
name: πŸ” Helm Validation (PR)
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: πŸ“¦ Checkout
uses: actions/checkout@v4

- name: πŸ” Check for Helm chart changes
uses: dorny/paths-filter@v3
id: changes
with:
filters: |
charts:
- 'charts/**'

- name: βš“ Install Helm
if: steps.changes.outputs.charts == 'true'
uses: azure/setup-helm@v4
with:
version: '3.14.0'

- name: πŸ“¦ Update Helm dependencies
if: steps.changes.outputs.charts == 'true'
run: |
cd charts/dataviz-srv
helm dependency update

- name: πŸ” Helm lint
if: steps.changes.outputs.charts == 'true'
run: |
helm lint charts/dataviz-srv

- name: βœ… Helm template validation
if: steps.changes.outputs.charts == 'true'
run: |
helm template dataviz-srv charts/dataviz-srv --values charts/dataviz-srv/values.yaml --dry-run

- name: πŸ“Š Helm chart diff (if applicable)
if: steps.changes.outputs.charts == 'true'
run: |
echo "::notice title=Helm Changes::Helm chart changes detected in this PR. Please review the modifications."
Loading