Publish Helm charts #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Helm Charts | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- "charts/**" | |
tags: | |
- "chart-*" | |
workflow_dispatch: | |
jobs: | |
release-charts: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Install Helm | |
run: | | |
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | |
chmod 700 get_helm.sh | |
./get_helm.sh | |
- name: Install GitHub CLI | |
run: | | |
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg | |
echo "deb [signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null | |
sudo apt update | |
sudo apt install gh | |
- name: Package and Release Helm charts | |
run: | | |
mkdir ./release | |
for chart in charts/*; do | |
if [ -d "$chart" ]; then | |
chart_name=$(basename "$chart") | |
helm package "$chart" --destination ./release | |
chart_version=$(grep 'version:' "$chart/Chart.yaml" | cut -d ' ' -f 2) | |
chart_file="${chart_name}-${chart_version}.tgz" | |
echo "Processing $chart_file..." | |
git_tag="chart-${chart_name}-${chart_version}" | |
release_name="${chart_name} Chart Release ${chart_version}" | |
echo "Creating GitHub Release $release_name..." | |
gh release create "$git_tag" "./release/$chart_file" --title "$release_name" --notes "Release of $chart_name version $chart_version" | |
echo "$chart_name chart released successfully." | |
fi | |
done | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Setup Git for GitHub Pages | |
run: | | |
git config user.name "github-actions" | |
git config user.email "github-actions@github.com" | |
git fetch --depth=1 origin gh-pages | |
git checkout -b gh-pages origin/gh-pages | |
- name: Update index.yaml | |
run: | | |
helm repo index ./release --url https://github.com/cloudforet-io/charts/releases/download/ | |
git add ./release/index.yaml | |
git commit -s -m "Update index.yaml" | |
git push origin gh-pages |