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: Deploy New Helm Chart to gh-pages | ||
on: | ||
push: | ||
branches: | ||
- main # Trigger on pushes to the main branch | ||
paths: | ||
- "**/Chart.yaml" # Trigger only if a Chart.yaml file is added | ||
jobs: | ||
deploy-chart: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Main Branch | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # Fetch entire history to detect additions | ||
- name: Install Helm | ||
run: | | ||
curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash | ||
- name: Identify Newly Added Charts | ||
id: find-new-charts | ||
run: | | ||
# Find directories with newly added Chart.yaml | ||
NEW_CHARTS=$(git diff --name-status HEAD^ HEAD | grep "^A" | grep "Chart.yaml" | awk '{print $2}' | xargs -n1 dirname) | ||
echo "new_charts=$NEW_CHARTS" >> $GITHUB_ENV | ||
- name: Debug New Charts | ||
run: echo "New Charts: ${{ env.new_charts }}" | ||
- name: Package New Helm Charts | ||
if: env.new_charts != "" | ||
run: | | ||
mkdir -p packaged-charts | ||
for chart in ${{ env.new_charts }}; do | ||
helm package $chart --destination packaged-charts | ||
done | ||
- name: Checkout gh-pages Branch | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: gh-pages # Check out the gh-pages branch | ||
- name: Copy Packaged Charts | ||
if: env.new_charts != "" | ||
run: | | ||
mkdir -p charts | ||
mv ../packaged-charts/*.tgz charts/ | ||
- name: Update Helm Repo Index | ||
if: env.new_charts != "" | ||
run: | | ||
helm repo index charts --url https://nodeify-eth.github.io/helm-charts/charts/ | ||
- name: Commit and Push Changes | ||
if: env.new_charts != "" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
git config --global user.name "github-actions[bot]" | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
git add charts | ||
git commit -m "Add new Helm chart(s) and update index" | ||
git push |