name: "Charts: Release" concurrency: helm-release on: workflow_dispatch: push: branches: - main paths: - "charts/**" jobs: release-charts: runs-on: ubuntu-22.04 steps: - name: Get k8s-at-home token id: get-app-token uses: getsentry/action-github-app-token@v1 with: app_id: ${{ secrets.BJWS_APP_ID }} private_key: ${{ secrets.BJWS_APP_PRIVATE_KEY }} - name: Checkout charts branch uses: actions/checkout@v3 with: token: ${{ steps.get-app-token.outputs.token }} path: 'src' fetch-depth: 0 - name: Collect changes uses: dorny/paths-filter@v2 id: filter with: list-files: shell working-directory: src filters: | chartsAddedOrModified: - added|modified: 'charts/*/**' - name: Collect changed charts if: | steps.filter.outputs.chartsAddedOrModified == 'true' id: filter-charts shell: bash run: | CHARTS=() PATHS=(${{ steps.filter.outputs.chartsAddedOrModified_files }}) # Get only the chart paths for CHARTPATH in "${PATHS[@]}" do IFS='/' read -r -a path_parts <<< "${CHARTPATH}" CHARTS+=("${path_parts[1]}/${path_parts[2]}") done # Remove duplicates CHARTS=( `printf "%s\n" "${CHARTS[@]}" | sort -u` ) # Set output to changed charts printf "::set-output name=addedOrModifiedCharts::%s\n" "${CHARTS[*]}" - name: Checkout gh-pages branch uses: actions/checkout@v3 with: token: ${{ steps.get-app-token.outputs.token }} path: 'dest' ref: 'gh-pages' fetch-depth: 0 - name: Install Helm uses: Azure/setup-helm@v3.3 - name: Package Helm Charts shell: bash env: SRC_DIR: "src/charts" DEST_DIR: "dest" CHARTS: "${{ steps.filter-charts.outputs.addedOrModifiedCharts }}" run: | for CHART in $CHARTS ; do mapfile -t CHART_PATH_PARTS < <(echo "$CHART" | tr '/' '\n') CHART_TYPE=${CHART_PATH_PARTS[2]} helm dep up "$CHART" helm package "$CHART" -u -d "$DEST_DIR/$CHART_TYPE" done # - name: Create new index # shell: bash # working-directory: dest # run: | # helm repo index . --url https://bjw-s.github.io/helm-charts/ # - name: Push changes # shell: bash # working-directory: dest # run: | # git config user.name "bjw-s-bot[bot]" # git config user.email "bjw-s-bot <87358111+bjw-s-bot[bot]@users.noreply.github.com>" # git add $(git ls-files -o --exclude-standard) # git add index.yaml # git commit -m "Updated from ref: $GITHUB_SHA" # git push