Skip to content

Helm repo index

Helm repo index #148

Workflow file for this run

name: Helm repo index
on:
push:
branches:
- 'master'
- 'main'
workflow_dispatch:
repository_dispatch:
jobs:
index:
name: "Build index"
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: "actions/checkout@v2"
with:
ref: ${{ github.ref }}
- name: Gather Charts, build index, and update readme
run: |
# define array for later use
charts=()
# download and package charts
while read line; do
# Create temp working dir
mkdir tmp
cd tmp
# split the row to get the variables from chartsources.txt
REPOSITORY=$(echo "$line" | cut -d ";" -f 1)
CHARTDIR=$(echo "$line" | cut -d ";" -f 2)
FRIENDLYNAME=$(echo "$line" | cut -d ";" -f 3)
# add chart to array
charts+=("- [$FRIENDLYNAME]($REPOSITORY)")
# Clone repository
git clone "$REPOSITORY" .
# Package chart from specified chart dir
helm package -d ../_releases "./$CHARTDIR"
# backout and delete tmp dir
cd ..
rm -rf tmp
done <chartsources.txt
# Update the index
helm repo index ./_releases/ --url https://github.com/jonfairbanks/helm-charts/raw/master/_releases/
rm -rf index.yaml
mv ./_releases/index.yaml index.yaml
# Delete listed charts in readme
sed -i '/^### Charts/,$d' README.md
# Add header and each chart as a new line to README.md
sed -i -e '$a\### Charts\' README.md
for chart in "${charts[@]}"
do
echo "$chart" >>README.md
done
- name: Commit changes
uses: EndBug/[email protected]
with:
message: "Automatically rebuild sources and index"
push: "origin ${{ github.event.repository.default_branch }} --force"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}