name: "Charts: Release to GitHub pages" on: workflow_call: inputs: charts: description: > Json encoded list of Helm charts to release. Defaults to releasing everything. default: "[]" required: false type: string secrets: BJWS_APP_ID: required: true BJWS_APP_PRIVATE_KEY: required: true env: HELM_VERSION: 3.11.2 jobs: release-charts: name: Release charts runs-on: ubuntu-22.04 steps: - name: "Generate Short Lived OAuth App Token (ghs_*)" uses: actions/create-github-app-token@v1.8.1 id: app-token with: app-id: "${{ secrets.BJWS_APP_ID }}" private-key: "${{ secrets.BJWS_APP_PRIVATE_KEY }}" - name: Checkout charts branch uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 with: token: ${{ steps.app-token.outputs.token }} path: "src" fetch-depth: 0 - name: Checkout gh-pages branch uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 with: token: ${{ steps.app-token.outputs.token }} path: "dest" ref: "gh-pages" fetch-depth: 0 - name: Install Kubernetes tools uses: yokawasa/action-setup-kube-tools@v0.10.0 with: setup-tools: | helmv3 helm: "${{ env.HELM_VERSION }}" - name: Package Helm Charts shell: bash env: SRC_DIR: "src/charts" DEST_DIR: "dest" run: | CHARTS=( $(yq --null-input e '${{ inputs.charts }}[]' ) ) for CHART in "${CHARTS[@]}" ; do mapfile -t CHART_PATH_PARTS < <(echo "$CHART" | tr '/' '\n') CHART_TYPE=${CHART_PATH_PARTS[0]} helm package "${SRC_DIR}/${CHART}" --dependency-update --destination "${DEST_DIR}/${CHART_TYPE}" done - name: Update chart index shell: bash working-directory: dest run: | helm repo index . --url https://bjw-s.github.io/helm-charts/ - name: Commit changes uses: stefanzweifel/git-auto-commit-action@v5 id: auto-commit with: repository: dest branch: gh-pages commit_user_name: "bjw-s-bot[bot]" commit_user_email: 87358111+bjw-s-bot[bot]@users.noreply.github.com commit_author: bjw-s-bot[bot] <87358111+bjw-s-bot[bot]@users.noreply.github.com> file_pattern: "index.yaml **/*.tgz" disable_globbing: true - name: Wait for deploy uses: fountainhead/action-wait-for-check@v1.1.0 if: ${{ steps.auto-commit.outputs.changes_detected }} id: wait-for-deploy with: token: ${{ steps.app-token.outputs.token }} ref: ${{ steps.auto-commit.outputs.commit_hash }} checkName: deploy