fix publishing of docs to include helm chart (#162) #9
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: Release Charts and publish docs | |
# It's important that these 2 steps happen in sequence because they | |
# both need to push a commit to the gh-pages branch. | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
release-charts: | |
# depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions | |
# see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Configure Git | |
run: | | |
git config user.name "$GITHUB_ACTOR" | |
git config user.email "$GITHUB_ACTOR@users.noreply.github.com" | |
- name: Install Helm | |
uses: azure/setup-helm@v4 | |
env: | |
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
- name: Run chart-releaser | |
uses: helm/chart-releaser-action@v1.6.0 | |
env: | |
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
CR_SKIP_EXISTING: "true" | |
CR_RELEASE_NAME_TEMPLATE: "kubeai-helm-chart-{{ .Version }}" | |
- name: Copy index.yaml from gh-pages branch to main branch docs/index.yaml | |
run: | | |
git checkout gh-pages | |
git pull origin gh-pages | |
cp index.yaml /tmp/index.yaml | |
git checkout main | |
mkdir -p docs | |
mv /tmp/index.yaml docs/index.yaml | |
# check if the file is modified returns exit code 1 if it is | |
git diff --exit-code docs/index.yaml | |
if [ $? -eq 1 ]; then | |
git add docs/index.yaml | |
git commit -m "CI: Copy index.yaml from gh-pages to main" | |
git push | |
exit 0 | |
fi | |
echo "No changes to index.yaml" | |
publish-docs: | |
needs: release-charts | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Configure Git Credentials | |
run: | | |
git config user.name github-actions[bot] | |
git config user.email 41898282+github-actions[bot]@users.noreply.github.com | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV | |
- uses: actions/cache@v4 | |
with: | |
key: mkdocs-material-${{ env.cache_id }} | |
path: .cache | |
restore-keys: | | |
mkdocs-material- | |
- run: pip install -r docs/requirements.txt | |
- run: git fetch origin && mkdocs gh-deploy |