Skip to content

Generate and Sync CLI Docs #17

Generate and Sync CLI Docs

Generate and Sync CLI Docs #17

Workflow file for this run

name: Generate and Sync CLI Docs
on:
# push:
# branches:
# - main
# paths:
# - 'cli/**' # Adjust this to match your CLI code structure
# - 'gen/docs.md/**' # If the generator is in a separate directory
workflow_dispatch:
inputs:
branch:
description: 'docs section to update'
type: choice
options:
- stable
- develop
concurrency:
group: sync-docs
jobs:
generate-and-sync-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout CLI repository
uses: actions/checkout@v4
with:
path: cli-repo
- name: checkout docs repo
run: |
git clone https://github.com/ksctl/docs.git docs-repo
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 'stable'
- name: Generate Documentation
working-directory: cli-repo
run: |
make gen-docs
- name: Sync Generated Docs
run: |
# Copy generated docs
cp -rv cli-repo/gen/docs.md/. docs-repo/content/en/docs/${{ github.event.inputs.branch }}/Reference/.
ls -l docs-repo/content/en/docs/${{ github.event.inputs.branch }}/Reference/
- name: Commit and Push Changes
working-directory: docs-repo
# env:
# GITHUB_TOKEN: ${{ secrets.PAT_SYNC_CLI_DOCS_TO_DOCS_REPO }}
run: |
git config user.name "Dipankar Das"
git config user.email "[email protected]"
git remote add docs https://${{ secrets.PAT_SYNC_CLI_DOCS_TO_DOCS_REPO }}@github.com/ksctl/docs.git
git add content/en/docs/${{ github.event.inputs.branch }}/Reference
git remote -v
git branch -v
git diff --quiet && git diff --staged --quiet || (git commit -m "chore(cicd): Update CLI documentation" && git push docs main)