Simplify Helm workflow to build on main branch only
- Removed tag-based triggers and release creation - Renamed workflow from helm-release.yml to helm-build.yml - Simplified to always build and publish on main branch push - Version always comes from Chart.yaml (no modifications) - Removed all release-related logic and conditions - Kept PR linting for validation - Cleaner and simpler workflow focused on continuous delivery - Updated README to reflect the new workflow structure
This commit is contained in:
101
.gitea/workflows/helm-build.yml
Normal file
101
.gitea/workflows/helm-build.yml
Normal file
@@ -0,0 +1,101 @@
|
||||
name: Helm Chart Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-helm:
|
||||
runs-on: ubuntu-latest
|
||||
# Only run on main branch pushes (not on PRs)
|
||||
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
|
||||
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: Get chart version
|
||||
run: |
|
||||
# Get version from Chart.yaml
|
||||
VERSION=$(grep '^version:' helm/api7ee-demo-k8s/Chart.yaml | awk '{print $2}')
|
||||
echo "📌 Chart version: ${VERSION}"
|
||||
echo "VERSION=${VERSION}" >> $GITHUB_ENV
|
||||
|
||||
- name: Lint Helm chart
|
||||
run: |
|
||||
helm lint helm/api7ee-demo-k8s/
|
||||
|
||||
- name: Prepare and package Helm chart
|
||||
run: |
|
||||
# Create a temporary copy of the chart for packaging
|
||||
cp -r helm/api7ee-demo-k8s /tmp/api7ee-demo-k8s-chart
|
||||
|
||||
# Update image registry and repository to match Gitea
|
||||
sed -i "s|registry: gitea.server_url|registry: ${{ gitea.server_url }}|g" /tmp/api7ee-demo-k8s-chart/values.yaml
|
||||
sed -i "s|repository: gitea.repository/|repository: ${{ gitea.repository }}/|g" /tmp/api7ee-demo-k8s-chart/values.yaml
|
||||
|
||||
# Package the chart
|
||||
helm package /tmp/api7ee-demo-k8s-chart
|
||||
|
||||
# Store chart filename
|
||||
echo "CHART_FILE=api7ee-demo-k8s-${VERSION}.tgz" >> $GITHUB_ENV
|
||||
echo "📦 Packaged chart: api7ee-demo-k8s-${VERSION}.tgz"
|
||||
|
||||
- name: Push Helm chart to Gitea Package Registry
|
||||
run: |
|
||||
# Upload Helm chart to Gitea package registry
|
||||
echo "📤 Uploading chart to Gitea Package Registry..."
|
||||
|
||||
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: Summary
|
||||
run: |
|
||||
echo "## 📦 Helm Chart Published"
|
||||
echo ""
|
||||
echo "- **Version:** ${VERSION}"
|
||||
echo "- **Chart:** ${CHART_FILE}"
|
||||
echo "- **Registry:** https://${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/helm"
|
||||
echo ""
|
||||
echo "### Installation"
|
||||
echo '```bash'
|
||||
echo "helm repo add api7ee https://${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/helm"
|
||||
echo "helm repo update"
|
||||
echo "helm install my-api7ee api7ee/api7ee-demo-k8s --version ${VERSION}"
|
||||
echo '```'
|
||||
|
||||
lint-only:
|
||||
runs-on: ubuntu-latest
|
||||
# Only run on PRs
|
||||
if: github.event_name == 'pull_request'
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Helm
|
||||
uses: azure/setup-helm@v3
|
||||
with:
|
||||
version: "latest"
|
||||
|
||||
- name: Lint Helm chart
|
||||
run: |
|
||||
echo "🔍 Linting Helm chart for PR..."
|
||||
helm lint helm/api7ee-demo-k8s/
|
||||
echo "✅ Helm chart linting passed"
|
||||
Reference in New Issue
Block a user