Workflow to build CLI docs update PR when a vCluster PR has been merged #13
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: cli-docs | |
on: | |
pull_request: | |
types: [edited, ready_for_review, converted_to_draft] | |
repository_dispatch: | |
types: [ update-cli-docs ] | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout vcluster repository | |
uses: actions/checkout@v4 | |
with: | |
repository: loft-sh/vcluster | |
fetch-depth: 0 | |
ref: ${{ github.event.client_payload.ref }} | |
path: vcluster-repo | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: "1.22" | |
- name: Setup Just | |
uses: extractions/setup-just@v2 | |
- name: Generate cli docs | |
working-directory: vcluster-repo | |
run: just generate-cli-docs | |
- uses: actions/checkout@v4 | |
with: | |
repository: loft-sh/vcluster-docs | |
fetch-depth: 0 | |
path: vcluster-docs | |
- name: Copy generated files | |
env: | |
PR_TITLE: ${{ github.event.client_payload.title || 'No title' }} | |
PR_REF: ${{ github.event.client_payload.ref || 'main' }} | |
PR_VERSION: ${{ github.event.client_payload.version || 'wip-version' }} | |
run: | | |
# set git info | |
git config --global user.name "Loft Bot" | |
git config --global user.email '[email protected]' | |
cp -r ./vcluster-repo/docs/pages/cli vcluster-docs/vcluster | |
cd vcluster-docs | |
git checkout -b "CLI-DOC-$PR_REF" | |
git add ./vcluster/cli | |
# if there are no changes, exit early | |
if git diff-index --quiet HEAD --; then | |
exit 0 | |
fi | |
git commit -m "DOC Update from $PR_TITLE" | |
git push origin "CLI-DOC-$PR_REF" | |
gh pr create --base main -t "DOC Update from $PR_TITLE" --body "Autogenerated PR for CLI docs" | |