Skip to content

Auto generate and publish CLI docs on each release #832

Auto generate and publish CLI docs on each release

Auto generate and publish CLI docs on each release #832

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@v2
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
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
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
# TODO: replace yuandrew with ${{ github.event.release.author.login }}
# can this not be done until we "release"?
# Query the GitHub API for the release author
API_RESPONSE=$(curl -s -H "Authorization: Bearer ${{ steps.generate_token.outputs.token }}" \
https://api.github.com/users/yuandrew)
# Extract the email field from the API response
AUTHOR_LOGIN=$(echo "$API_RESPONSE" | jq -r '.author.login')
echo "author_login: $AUTHOR_LOGIN"
EMAIL=$(echo "$API_RESPONSE" | jq -r '.author.email')
echo "EMAIL: $EMAIL"
EMAIL=$(echo "$API_RESPONSE" | jq -r '.email')
echo "EMAIL: $EMAIL"
# If no public email is found, fallback to a default
if [ "$EMAIL" == "null" ]; then
echo "falling back on default email"
EMAIL="andrew.yuan@temporal.io"
# TODO: sdk@temporal.io
fi
# Setup the committers identity.
git config --global user.email "$EMAIL"
git config --global user.name "yuandrew"
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"