Skip to content

Build and Deploy Helm changelogs to Github Pages #11508

Build and Deploy Helm changelogs to Github Pages

Build and Deploy Helm changelogs to Github Pages #11508

Workflow file for this run

---
name: Build and Deploy Helm changelogs to Github Pages
on:
push:
branches: [main]
schedule:
- cron: "0 0-8/3 * * *"
- cron: "0 9-18 * * *"
- cron: "0 20-23/3 * * *"
env:
HELM_CHANGELOG_VERSION: 0.1.1
jobs:
helm_changelogs:
name: Build and deploy site
runs-on: ubuntu-24.04
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write
id-token: write
defaults:
run:
shell: bash
steps:
- name: Checkout BapRx/changelogs
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Check if there are new commits since last Github Action job
id: update_submodules
run: |
# Skip run if no new commit since last Github Action job
git submodule update --remote --recursive --init
git diff
if $(git diff --quiet)
then
echo "updated=false" >> $GITHUB_OUTPUT
fi
- name: Generate Helm Changelogs
run: |
# Download release ${HELM_CHANGELOG_VERSION} of helm-changelog
tmpdir=$(mktemp -d)
curl -fLsC - -o "$tmpdir/helm-changelog.tar.gz" "https://github.com/BapRx/helm-changelog/releases/download/v${HELM_CHANGELOG_VERSION}/helm-changelog_${HELM_CHANGELOG_VERSION}_linux_amd64.tar.gz"
tar zxvf "$tmpdir/helm-changelog.tar.gz" -C /usr/local/bin/ helm-changelog
# Delete pre-existing changelogs
find . -type f -name Changelog.md -delete
# Generate new changelogs
git submodule foreach helm-changelog -v info
# Process and move Changelog.md files to a specific directory
find . -type f -name Changelog.md -not -empty | while read line; do
directory_name=$(dirname $line)
chart_name=$(basename $directory_name)
repository=$(echo $directory_name | cut -d/ -f 2-3)
if [ ! -d "${GITHUB_WORKSPACE}/_changelogs/${repository//\//_}/" ]; then
mkdir "${GITHUB_WORKSPACE}/_changelogs/${repository//\//_}/"
echo -e "---\nhas_children: true\nlayout: default\npermalink: /${repository}\ntitle: ${repository}\n---\n\n# ${repository}" >"${GITHUB_WORKSPACE}/_changelogs/${repository//\//_}/index.md"
fi
sed -i '1i---\nlayout: default\nparent: '${repository}'\npermalink: /'${repository}'/'${chart_name}'\nrender_with_liquid: false\ntitle: '${chart_name}'\n---\n' $line
sed -i "s/^# Change Log$/# ${chart_name}/" $line
mv $line "${GITHUB_WORKSPACE}/_changelogs/${repository//\//_}/${chart_name}.md"
done
working-directory: repositories
if: ${{ steps.update_submodules.outputs.updated != 'false' || github.event_name != 'schedule' }}
- uses: actions/cache@v4
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile') }}
restore-keys: |
${{ runner.os }}-gems-
if: ${{ steps.update_submodules.outputs.updated != 'false' || github.event_name != 'schedule' }}
- name: Build Jekyll for GitHub Pages
uses: jeffreytse/[email protected]
with:
jekyll_src: ./
token: ${{ secrets.GITHUB_TOKEN }}
if: ${{ steps.update_submodules.outputs.updated != 'false' || github.event_name != 'schedule' }}
- name: Push updated submodules
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add repositories/ && git commit -m "[bot] Update submodules" && git push origin main || true
if: ${{ steps.update_submodules.outputs.updated != 'false' }}