patch: sync docs cicd #21
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: Generate and Sync CLI Docs | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'cli/**' # Adjust this to match your CLI code structure | |
- '.github/workflows/sync-docs.yml' | |
workflow_dispatch: | |
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 --branch dev 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: | | |
mkdir -p gen/docs.md | |
make gen-docs | |
- name: Sync Generated Docs | |
run: | | |
# Copy generated docs | |
cp docs-repo/content/en/docs/Reference/_index.md /tmp/_index.md | |
rm -rf docs-repo/content/en/docs/Reference | |
mkdir -p docs-repo/content/en/docs/Reference | |
cp /tmp/_index.md docs-repo/content/en/docs/Reference/_index.md | |
cp -rv cli-repo/gen/docs.md/. docs-repo/content/en/docs/Reference/. | |
ls -lha docs-repo/content/en/docs/Reference/ | |
- name: Commit and Push Changes | |
working-directory: docs-repo | |
run: | | |
git config user.name "github-actions[bot]" | |
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/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 dev) |