From 8d17daea37a0c29bd73d1eee000add9e6568bf61 Mon Sep 17 00:00:00 2001 From: Scott Rigby Date: Mon, 19 Oct 2020 12:44:14 -0400 Subject: [PATCH] GH Actions to automate gh-pages (#23921) * Sync chart repo READMEs to gh-pages Signed-off-by: Scott Rigby * Sync chart repos to gh-pages Signed-off-by: Scott Rigby * Combine helm dep and helm package Signed-off-by: Scott Rigby --- .github/workflows/sync-readmes.yaml | 27 ++++++ .github/workflows/sync-repos.yaml | 138 ++++++++++++++++++++++++++++ incubator/README.md | 29 ++++++ stable/README.md | 29 ++++++ 4 files changed, 223 insertions(+) create mode 100644 .github/workflows/sync-readmes.yaml create mode 100644 .github/workflows/sync-repos.yaml create mode 100644 incubator/README.md create mode 100644 stable/README.md diff --git a/.github/workflows/sync-readmes.yaml b/.github/workflows/sync-readmes.yaml new file mode 100644 index 0000000000..33bb71cce9 --- /dev/null +++ b/.github/workflows/sync-readmes.yaml @@ -0,0 +1,27 @@ +on: + push: + branches: + - 'master' + paths: + - 'stable/README.md' + - 'incubator/README.md' +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: | + mkdir -p ${{ runner.temp }}/stable ${{ runner.temp }}/incubator + cp -f stable/README.md ${{ runner.temp }}/stable/README.md + cp -f incubator/README.md ${{ runner.temp }}/incubator/README.md + - uses: actions/checkout@v2 + with: + ref: gh-pages + - run: | + cp -f ${{ runner.temp }}/stable/README.md stable + cp -f ${{ runner.temp }}/incubator/README.md incubator + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + git add stable/README.md incubator/README.md + git commit --signoff -m "Sync READMEs from master [ci skip]" + git push diff --git a/.github/workflows/sync-repos.yaml b/.github/workflows/sync-repos.yaml new file mode 100644 index 0000000000..e2c058c019 --- /dev/null +++ b/.github/workflows/sync-repos.yaml @@ -0,0 +1,138 @@ +on: + push: + branches: + - master + # Only bother running workflow if files in one of these subfolder have + # changed since most recent commit to master. + paths: + - 'stable/*/**' + - 'incubator/*/**' +jobs: + changes: + runs-on: ubuntu-latest + outputs: + stable: ${{ steps.filter.outputs.stable }} + incubator: ${{ steps.filter.outputs.incubator }} + stable_dirs: ${{ steps.dirs.outputs.stable_dirs }} + incubator_dirs: ${{ steps.dirs.outputs.incubator_dirs }} + steps: + - uses: actions/checkout@v2 + - uses: dorny/paths-filter@v2.5.0 + id: filter + with: + list-files: shell + filters: | + stable: + - added|modified: 'stable/*/**' + incubator: + - added|modified: 'incubator/*/**' + # Exports space-separated lists of changed chart dirs + # "xargs -n1" converts to newlines + # "cut -d/ -f 1-2" gets the first two dirs (example: stable/wordpress) + # "sort -u" gets sorted unique dirs + # "xargs" converts back to space-separated string + - id: dirs + run: | + echo "stable files: ${{ steps.filter.outputs.stable_files }}" + echo "incubator files: ${{ steps.filter.outputs.stable_files }}" + stable_dirs=$(echo ${{ steps.filter.outputs.stable_files }} | xargs -n1 | cut -d/ -f 1-2 | sort -u | xargs) + echo "::set-output name=stable_dirs::$stable_dirs" + echo "stable dirs: $stable_dirs" + incubator_dirs=$(echo ${{ steps.filter.outputs.incubator_files }} | xargs -n1 | cut -d/ -f 1-2 | sort -u | xargs) + echo "::set-output name=incubator_dirs::$incubator_dirs" + echo "incubator dirs: $incubator_dirs" + + package: + needs: changes + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: package stable + if: ${{ needs.changes.outputs.stable == 'true' }} + run: | + echo "dirs: ${{ needs.changes.outputs.stable_dirs }}" + mkdir -p ${{ runner.temp }}/stable/packages + for dir in ${{ needs.changes.outputs.stable_dirs }}; do + if helm package --dependency-update --destination ${{ runner.temp }}/stable/packages "$dir"; then + echo "✅ built dependencies and packaged $dir" + else + echo "❌ unable to build dependencies for $dir" + exit 1 + fi + done + - uses: actions/upload-artifact@v2 + if: ${{ needs.changes.outputs.stable == 'true' }} + with: + name: stable-packages + path: ${{ runner.temp }}/stable/packages/ + - name: package incubator + if: ${{ needs.changes.outputs.incubator == 'true' }} + run: | + mkdir -p ${{ runner.temp }}/incubator/packages + for dir in ${{ needs.changes.outputs.incubator_dirs }}; do + if helm package --dependency-update --destination ${{ runner.temp }}/incubator/packages "$dir"; then + echo "✅ built dependencies and packaged $dir" + else + echo "❌ unable to build dependencies for $dir" + exit 1 + fi + done + - uses: actions/upload-artifact@v2 + if: ${{ needs.changes.outputs.incubator == 'true' }} + with: + name: incubator-packages + path: ${{ runner.temp }}/incubator/packages/ + + index-release: + needs: + - changes + - package + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: gh-pages + - name: configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + - uses: actions/download-artifact@v2 + if: ${{ needs.changes.outputs.stable == 'true' }} + with: + name: stable-packages + path: ${{ runner.temp }}/stable/packages + - name: sync stable + if: ${{ needs.changes.outputs.stable == 'true' }} + run: | + if helm repo index --url https://charts.helm.sh/stable --merge stable/index.yaml ${{ runner.temp }}/stable; then + mv -f ${{ runner.temp }}/stable/index.yaml stable/index.yaml + git add stable/index.yaml + else + echo "❌ unable to update index" + exit 1 + fi + mkdir -p stable/packages + cp -f ${{ runner.temp }}/stable/packages/*.tgz stable/packages + git add stable/packages/*.tgz + git commit --signoff -m "Sync stable [ci skip]" + git push + - uses: actions/download-artifact@v2 + if: ${{ needs.changes.outputs.incubator == 'true' }} + with: + name: incubator-packages + path: ${{ runner.temp }}/incubator/packages + - name: sync incubator + if: ${{ needs.changes.outputs.incubator == 'true' }} + run: | + if helm repo index --url https://charts.helm.sh/stable/incubator --merge incubator/index.yaml ${{ runner.temp }}/incubator; then + mv -f ${{ runner.temp }}/incubator/index.yaml incubator/index.yaml + git add incubator/index.yaml + else + echo "❌ unable to update index" + exit 1 + fi + mkdir -p incubator/packages + cp -f ${{ runner.temp }}/incubator/packages/*.tgz incubator/packages + git add incubator/packages/*.tgz + git commit --signoff -m "Sync incubator [ci skip]" + git push diff --git a/incubator/README.md b/incubator/README.md new file mode 100644 index 0000000000..e639a0c340 --- /dev/null +++ b/incubator/README.md @@ -0,0 +1,29 @@ +# Helm Incubator + +[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) + +## Usage + +[Helm](https://helm.sh) must be installed to use the charts. +Please refer to Helm's [documentation](https://helm.sh/docs/) to get started. + +Once Helm is set up properly, add the repo as follows: + +```console +helm repo add incubator https://charts.helm.sh/incubator +``` + +You can then run `helm search repo incubator` to see the charts, or browse on CNCF [Artifact Hub](https://artifacthub.io/packages/search?page=1&repo=helm-incubator). + +## Contributing + + +⚠️ Note the [status of the project](https://github.com/helm/charts/blob/master/README.md#status-of-the-project), [deprecation timeline](https://github.com/helm/charts/blob/master/README.md#deprecation-timeline), and the ongoing effort to [relocate charts to new repos](https://github.com/helm/charts/issues/21103). + + +We'd love to have you contribute! Please refer to our [contribution guidelines](https://github.com/helm/charts/blob/master/CONTRIBUTING.md) for details. + +## License + + +[Apache 2.0 License](https://github.com/helm/charts/blob/master/LICENSE). diff --git a/stable/README.md b/stable/README.md new file mode 100644 index 0000000000..7d6837486b --- /dev/null +++ b/stable/README.md @@ -0,0 +1,29 @@ +# Helm Stable + +[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) + +## Usage + +[Helm](https://helm.sh) must be installed to use the charts. +Please refer to Helm's [documentation](https://helm.sh/docs/) to get started. + +Once Helm is set up properly, add the repo as follows: + +```console +helm repo add stable https://charts.helm.sh/stable +``` + +You can then run `helm search repo stable` to see the charts, or browse on CNCF [Artifact Hub](https://artifacthub.io/packages/search?page=1&repo=helm-stable). + +## Contributing + + +⚠️ Note the [status of the project](https://github.com/helm/charts/blob/master/README.md#status-of-the-project), [deprecation timeline](https://github.com/helm/charts/blob/master/README.md#deprecation-timeline), and the ongoing effort to [relocate charts to new repos](https://github.com/helm/charts/issues/21103). + + +We'd love to have you contribute! Please refer to our [contribution guidelines](https://github.com/helm/charts/blob/master/CONTRIBUTING.md) for details. + +## License + + +[Apache 2.0 License](https://github.com/helm/charts/blob/master/LICENSE).