From 6808b77aabb125880b4be4677cc5c706923063ff Mon Sep 17 00:00:00 2001 From: oshri barazani Date: Sun, 3 Nov 2024 18:16:22 +0200 Subject: [PATCH] fixe github action workflow --- .../generate-helm-html-index/action.yaml | 131 ------------------ .github/workflows/release.yaml | 34 ++++- .github/workflows/static.yml | 43 ------ 3 files changed, 27 insertions(+), 181 deletions(-) delete mode 100644 .github/actions/generate-helm-html-index/action.yaml delete mode 100644 .github/workflows/static.yml diff --git a/.github/actions/generate-helm-html-index/action.yaml b/.github/actions/generate-helm-html-index/action.yaml deleted file mode 100644 index f595e9b..0000000 --- a/.github/actions/generate-helm-html-index/action.yaml +++ /dev/null @@ -1,131 +0,0 @@ -# .github/actions/helm-chart-generator/action.yml -name: 'Helm Chart HTML Generator' -description: 'Generates a static HTML page from Helm chart index.yaml file' - -inputs: - index_file: - description: 'Path to the index.yaml file' - required: false - default: 'index.yaml' - output_file: - description: 'Output HTML file path' - required: false - default: 'index.html' - -runs: - using: "composite" - steps: - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - - name: Install Dependencies - shell: bash - run: | - python -m pip install --upgrade pip - pip install pyyaml - - - name: Run Generator Script - shell: python - env: - INDEX_FILE: ${{ inputs.index_file }} - OUTPUT_FILE: ${{ inputs.output_file }} - run: | - import os - import sys - import yaml - from datetime import datetime - - # Debug information - print("Environment variables:") - for key, value in os.environ.items(): - if key.startswith(('INDEX_', 'OUTPUT_')): - print(f"{key}: {value}") - - # Get input parameters directly from environment - index_file = os.environ['INDEX_FILE'] - output_file = os.environ['OUTPUT_FILE'] - - print(f"Looking for index file: {index_file}") - print(f"Will write to output file: {output_file}") - - # Verify input file exists - if not os.path.exists(index_file): - print(f"Error: Index file '{index_file}' not found!") - print(f"Absolute path attempted: {os.path.abspath(index_file)}") - sys.exit(1) - - # Read YAML file - try: - with open(index_file, 'r') as f: - data = yaml.safe_load(f) - except Exception as e: - print(f"Error reading YAML file: {e}") - sys.exit(1) - - # Generate HTML - html = f""" - - - - - - Helm Charts Repository - - - -

Helm Charts Repository

- """ - - # Add chart entries - for chart_name, versions in data.get('entries', {}).items(): - for version in versions: - html += f""" -
-
-

{chart_name}

- {f'Chart icon' if 'icon' in version else ''} -
-

{version.get('description', '')}

-
-

Version {version['version']}

-

App Version: {version.get('appVersion', 'N/A')}

-

Created: {version.get('created', 'N/A')}

- Download Chart -
-
- """ - - html += f""" - - - - """ - - # Write HTML file - try: - with open(output_file, 'w') as f: - f.write(html) - print(f"Successfully generated {output_file}") - except Exception as e: - print(f"Error writing HTML file: {e}") - sys.exit(1) \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 645b983..4d27d65 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -11,6 +11,9 @@ jobs: contents: write # to push chart release and create a release (helm/chart-releaser-action) runs-on: ubuntu-latest + outputs: + changed_charts: ${{ steps.chart-releaser.outputs.changed_charts }} + steps: - name: Checkout Code uses: actions/checkout@v4 @@ -28,6 +31,7 @@ jobs: - name: Run chart-releaser uses: helm/chart-releaser-action@v1.6.0 + id: chart-releaser env: CR_TOKEN: "${{ github.token }}" @@ -37,18 +41,13 @@ jobs: contents: write # Needed to commit the generated file needs: - release + if: needs.release.outputs.changed_charts != '' steps: - uses: actions/checkout@v4 with: ref: gh-pages fetch-depth: 0 - - name: debug-print - run: | - echo "Current directory is $(pwd)" - echo "Contents of the directory are $(ls -la)" - echo "Contents of the directory are $(ls -la /home/runner/work/helm-release/helm-release/)" - - name: Generate Helm Charts HTML uses: ./.github/actions/generate-helm-html-index with: @@ -61,4 +60,25 @@ jobs: git config --local user.name "GitHub Action" git add index.html git commit -m "Update Helm charts page" || exit 0 # Don't fail if no changes - git push \ No newline at end of file + git push + + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: + - generate-page + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Pages + uses: actions/configure-pages@v5 + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + # Upload entire repository + path: '.' + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml deleted file mode 100644 index b9c9160..0000000 --- a/.github/workflows/static.yml +++ /dev/null @@ -1,43 +0,0 @@ -# Simple workflow for deploying static content to GitHub Pages -name: Deploy static content to Pages - -on: - # Runs on pushes targeting the default branch - push: - branches: ["gh-pages"] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: read - pages: write - id-token: write - -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. -concurrency: - group: "pages" - cancel-in-progress: false - -jobs: - # Single deploy job since we're just deploying - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup Pages - uses: actions/configure-pages@v5 - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 - with: - # Upload entire repository - path: '.' - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4