Merge pull request #74 from geosolutions-it/gs_hostname_prefix_tomcat… #19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release Charts | |
| on: | |
| push: | |
| branches: [main] | |
| env: | |
| HELM_VERSION: v3.18.2 | |
| jobs: | |
| release-charts: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Helm | |
| uses: azure/setup-helm@v4 | |
| with: | |
| version: ${{ env.HELM_VERSION }} | |
| - name: Login to GHCR | |
| run: | | |
| echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io --username ${{ github.actor }} --password-stdin | |
| - name: Package and Push charts to GHCR | |
| run: | | |
| for chart_dir in */*/; do | |
| if [ -f "${chart_dir}Chart.yaml" ]; then | |
| chart_name=$(grep '^name:' "${chart_dir}Chart.yaml" | awk '{print $2}' | tr -d '"' | tr -d "'") | |
| chart_version=$(grep '^version:' "${chart_dir}Chart.yaml" | awk '{print $2}' | tr -d '"' | tr -d "'") | |
| echo "Processing $chart_name:$chart_version" | |
| if helm pull "oci://ghcr.io/geosolutions-it/charts/$chart_name" --version "$chart_version" --destination /tmp >/dev/null 2>&1; then | |
| echo "Chart is already exists, skipping..." | |
| rm -f /tmp/${chart_name}-${chart_version}.tgz 2>/dev/null | |
| continue | |
| fi | |
| helm package "$chart_dir" | |
| package_file="${chart_name}-${chart_version}.tgz" | |
| if [ -f "$package_file" ]; then | |
| helm push "$package_file" oci://ghcr.io/geosolutions-it/charts | |
| echo "✅ Pushed $chart_name:$chart_version" | |
| rm "$package_file" | |
| fi | |
| fi | |
| done | |
| - name: Checkout GitOps Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: geosolutions-it/gitops-dev | |
| token: ${{ secrets.GITOPS_DEV_TOKEN }} | |
| path: gitops-dev | |
| - name: Deploy to Dev (GitOps) | |
| run: | | |
| cd gitops-dev | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| changes_made=false | |
| for chart_dir in ../*/*/; do | |
| if [ -f "${chart_dir}Chart.yaml" ]; then | |
| chart_name=$(grep '^name:' "${chart_dir}Chart.yaml" | awk '{print $2}' | tr -d '"' | tr -d "'") | |
| chart_version=$(grep '^version:' "${chart_dir}Chart.yaml" | awk '{print $2}' | tr -d '"' | tr -d "'") | |
| if [ -d "apps/$chart_name" ]; then | |
| current_version=$(grep -A 5 'repoURL: ghcr.io' "apps/$chart_name/application.yaml" | grep 'targetRevision:' | awk '{print $2}' | tr -d '"' | tr -d "'") | |
| if [ "$current_version" = "$chart_version" ]; then | |
| echo "$chart_name version $chart_version is already deployed, skipping..." | |
| continue | |
| fi | |
| echo "Updating $chart_name from $current_version to $chart_version in GitOps repository" | |
| sed -i "/repoURL: ghcr.io/,/targetRevision:/ s/targetRevision: .*/targetRevision: $chart_version/" "apps/$chart_name/application.yaml" | |
| git add "apps/$chart_name/application.yaml" | |
| git commit -m "chore: update $chart_name chart version from $current_version to $chart_version" | |
| changes_made=true | |
| echo "Updated $chart_name to version $chart_version" | |
| else | |
| echo "App directory for $chart_name not found in GitOps repository" | |
| fi | |
| fi | |
| done | |
| if [ "$changes_made" = true ]; then | |
| git push origin HEAD | |
| echo "✅ GitOps repository updated successfully" | |
| else | |
| echo "📄 No version changes needed - all charts are already at the correct versions" | |
| fi |