--- name: "Charts: Release" concurrency: helm-release on: workflow_dispatch: inputs: charts: description: "JSON encoded list of charts to release" required: true type: string default: "[]" push: branches: - main paths: - "charts/**" jobs: prepare: name: Prepare data required for workflow runs-on: ubuntu-22.04 outputs: repoConfiguration: ${{ steps.repo-config.outputs.config }} libraryChartsToRelease: |- ${{ github.event_name == 'workflow_dispatch' && steps.specified-charts.outputs.libraryChartsToRelease || steps.changed-library-charts.outputs.all_changed_files }} otherChartsToRelease: |- ${{ github.event_name == 'workflow_dispatch' && steps.specified-charts.outputs.otherChartsToRelease || steps.changed-charts.outputs.all_changed_files }} steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - name: Grab repository configuration id: repo-config shell: bash run: | echo "config=$(yq '.' '.ci/repo-config.yaml' -o json -I=0)" >> "$GITHUB_OUTPUT" - name: Get changed library charts id: changed-library-charts if: ${{ github.event_name != 'workflow_dispatch' }} uses: tj-actions/changed-files@v45 with: matrix: true path: charts dir_names: true dir_names_max_depth: 2 files: | library/** - name: Get changed charts id: changed-charts if: ${{ github.event_name != 'workflow_dispatch' }} uses: tj-actions/changed-files@v45 with: matrix: true path: charts dir_names: true dir_names_max_depth: 2 files_ignore: | library/** - name: Get specified charts id: specified-charts if: ${{ github.event_name == 'workflow_dispatch' }} uses: actions/github-script@v7 with: script: | let input = '${{ github.event.inputs.charts }}'; let cwd = process.cwd(); let tmpCharts = [] if (input === '[]') { console.log("Empty charts input, scanning for charts in repository"); const globber = await glob.create('charts/*/*', { implicitDescendants: false }); for await (const file of globber.globGenerator()) { relativePath = file.slice(`${cwd}/charts/`.length); tmpCharts.push(relativePath); } } else { const fs = require('fs'); tmpCharts = JSON.parse(input); tmpCharts.forEach(function (chart) { if (!fs.existsSync(`${cwd}/charts/${chart}`)) { core.setFailed(`Chart ${chart} does not exist in repository`); process.exit(1); } }); } let libraryCharts = tmpCharts.filter(chart => chart.startsWith('library/')); let otherCharts = tmpCharts.filter(chart => !chart.startsWith('library/')); console.log("Library charts:") console.log(JSON.stringify(libraryCharts)); core.setOutput('libraryChartsToRelease', JSON.stringify(libraryCharts)); console.log("Other charts:") console.log(JSON.stringify(otherCharts)); core.setOutput('otherChartsToRelease', JSON.stringify(otherCharts)); release-library-charts: name: Release library charts needs: - prepare if: ${{ needs.prepare.outputs.libraryChartsToRelease != '[]' && needs.prepare.outputs.libraryChartsToRelease != '' }} uses: ./.github/workflows/charts-release-steps.yaml permissions: pages: write id-token: write contents: write packages: write with: charts: ${{ needs.prepare.outputs.libraryChartsToRelease }} excludedChartsRelease: ${{ toJSON(fromJSON(needs.prepare.outputs.repoConfiguration).excluded-charts-release) }} ghPagesBranch: gh-pages publishToOciRegistry: false release-other-charts: name: Release other charts needs: - prepare - release-library-charts if: |- ${{ !cancelled() && (needs.prepare.result == 'skipped' || needs.prepare.result == 'success') && (needs.release-library-charts.result == 'skipped' || needs.release-library-charts.result == 'success') && needs.prepare.outputs.otherChartsToRelease != '[]' }} uses: ./.github/workflows/charts-release-steps.yaml permissions: pages: write id-token: write contents: write packages: write with: charts: ${{ needs.prepare.outputs.otherChartsToRelease }} excludedChartsRelease: ${{ toJSON(fromJSON(needs.prepare.outputs.repoConfiguration).excluded-charts-release) }} ghPagesBranch: gh-pages