Skip to content

Auto generate and publish CLI docs on each release #835

Auto generate and publish CLI docs on each release

Auto generate and publish CLI docs on each release #835

Workflow file for this run

name: Continuous Integration
on:
pull_request:
workflow_dispatch:
release:
types: [published]
jobs:
update:
runs-on: ubuntu-latest
permissions:
contents: write
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
path: cli
submodules: recursive
- name: Generate token
id: generate_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.TEMPORAL_CICD_APP_ID }}
private-key: ${{ secrets.TEMPORAL_CICD_PRIVATE_KEY }}
- name: Checkout docs repo
uses: actions/checkout@v4
with:
repository: temporalio/documentation
persist-credentials: true
token: ${{ steps.generate_token.outputs.token }}
path: docs
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Generate CLI docs
run: |
cd cli/temporalcli/internal/cmd/gen-docs
go run .
- name: Publish generated docs to documentation repo
env:
GH_TOKEN: ${{ github.generate_token.outputs.token }}
run: |
set -e
set -x
BRANCH_NAME="cli-update-docs-${{ github.ref_name }}"
# Remove the "/merge" suffix if it exists
BRANCH_NAME=${BRANCH_NAME%/merge}
echo "Branch name: $BRANCH_NAME"
cd docs
pwd
# Setup the committers identity.
git config --global user.email "sdk@temporal.io"
git config --global user.name "Temporal CLI"
# git remote set-url origin https://temporal-cicd:${{ steps.generate_token.outputs.token }}@github.com/temporalio/documentation.git
git checkout -b $BRANCH_NAME
cp ../cli/temporalcli/docs/*.mdx docs/cli/
git add .
# TODO: mention CLI release version
git commit -m "CLI docs update, autogenerated on CLI release $LATEST_TAG, ${{ github.ref_name }}"
git push origin "$BRANCH_NAME"
gh pr create \
--body "Autogenerated PR from https://github.com/temporalio/cli" \
--title "CLI docs update $LATEST_TAG" \
--head "$BRANCH_NAME" \
--base "main"