Files
api7-demo/.gitea/workflows/build.yml
d.viti d818ee6600 Add Helm chart build and publishing to Gitea workflows
- Added Helm chart build job to main CI/CD workflow
- Created dedicated helm-release workflow for version tags
- Integrated Helm packaging with Gitea package registry
- Added automatic chart versioning and publishing
- Updated README with Helm deployment instructions
- Configured chart linting and validation steps
- Added release automation for tagged versions
2025-10-03 01:56:36 +02:00

146 lines
5.1 KiB
YAML

name: Build and Deploy
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
build-web:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
if: github.event_name == 'push'
uses: docker/login-action@v3
with:
registry: ${{ vars.PACKAGES_REGISTRY || gitea.server_url }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PACKAGES_PUSH_TOKEN }}
- name: Extract metadata for web image
id: meta-web
uses: docker/metadata-action@v5
with:
images: ${{ vars.PACKAGES_REGISTRY || gitea.server_url }}/${{ gitea.repository }}/web
tags: |
type=ref,event=branch
- name: Build and push web image
uses: docker/build-push-action@v5
with:
context: ./web
file: ./web/Dockerfile
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.meta-web.outputs.tags }}
labels: ${{ steps.meta-web.outputs.labels }}
cache-from: type=registry,ref=${{ vars.PACKAGES_REGISTRY || gitea.server_url }}/${{ gitea.repository }}/web:buildcache
cache-to: type=registry,ref=${{ vars.PACKAGES_REGISTRY || gitea.server_url }}/${{ gitea.repository }}/web:buildcache,mode=max
build-api:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
if: github.event_name == 'push'
uses: docker/login-action@v3
with:
registry: ${{ vars.PACKAGES_REGISTRY || gitea.server_url }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PACKAGES_PUSH_TOKEN }}
- name: Extract metadata for api image
id: meta-api
uses: docker/metadata-action@v5
with:
images: ${{ vars.PACKAGES_REGISTRY || gitea.server_url }}/${{ gitea.repository }}/api
tags: |
type=ref,event=branch
- name: Build and push api image
uses: docker/build-push-action@v5
with:
context: ./api
file: ./api/Dockerfile
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.meta-api.outputs.tags }}
labels: ${{ steps.meta-api.outputs.labels }}
cache-from: type=registry,ref=${{ vars.PACKAGES_REGISTRY || gitea.server_url }}/${{ gitea.repository }}/api:buildcache
cache-to: type=registry,ref=${{ vars.PACKAGES_REGISTRY || gitea.server_url }}/${{ gitea.repository }}/api:buildcache,mode=max
build-helm:
runs-on: ubuntu-latest
needs: [build-web, build-api]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for proper versioning
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: 'latest'
- name: Update Chart dependencies
run: |
cd helm/api7ee
helm dependency update
- name: Lint Helm chart
run: |
helm lint helm/api7ee/
- name: Package Helm chart
run: |
# Get version from Chart.yaml
CHART_VERSION=$(grep '^version:' helm/api7ee/Chart.yaml | awk '{print $2}')
# Update image registry in values.yaml to match Gitea registry
sed -i "s|registry: gitea.server_url|registry: ${{ gitea.server_url }}|g" helm/api7ee/values.yaml
# Package the chart
helm package helm/api7ee/ --version ${CHART_VERSION}
# Store chart filename for later use
echo "CHART_FILE=api7ee-${CHART_VERSION}.tgz" >> $GITHUB_ENV
- name: Push Helm chart to Gitea Package Registry
run: |
# Upload Helm chart to Gitea package registry
# Format: https://{gitea-server}/api/packages/{owner}/helm/api/charts
curl --fail-with-body \
-H "Authorization: token ${{ secrets.PACKAGES_PUSH_TOKEN }}" \
-X POST \
-F "chart=@${CHART_FILE}" \
https://${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/helm/api/charts
echo "✅ Helm chart pushed successfully to Gitea Package Registry"
echo "📦 Chart: ${CHART_FILE}"
echo "🔗 Registry URL: https://${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/helm"
- name: Create Helm index
if: success()
run: |
# Create or update the Helm repository index
echo "📝 Helm chart repository information:"
echo "To add this repository:"
echo " helm repo add api7ee https://${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/helm"
echo " helm repo update"
echo ""
echo "To install the chart:"
echo " helm install my-api7ee api7ee/api7ee"