Skip to content

Auto generate and publish CLI docs on each release #875

Auto generate and publish CLI docs on each release

Auto generate and publish CLI docs on each release #875

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
pull-requests: write
repository-projects: write
defaults:
run:
shell: bash
steps:
- 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 repository
uses: actions/checkout@v4
with:
path: cli
submodules: recursive
persist-credentials: true
token: ${{ steps.generate_token.outputs.token }}
- 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: Get user info from GitHub API
id: get_user
run: |
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/users/${{ github.actor }} > user.json
name=$(jq -r .name user.json)
email="${{ github.actor }}@users.noreply.github.com" # fallback
echo "git_name=$name" >> $GITHUB_OUTPUT
echo "git_email=$email" >> $GITHUB_OUTPUT
- name: Publish generated docs to documentation repo
env:
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
set -e
set -x
if [ -z "$GH_TOKEN" ]; then
echo "GH_TOKEN is NOT set"
exit 1
else
echo "GH_TOKEN is set"
fi
BRANCH_NAME="cli-update-docs-${{ github.ref_name }}"
# Remove the "/merge" suffix if it exists
BRANCH_NAME=${BRANCH_NAME%/merge}
cd docs
# Setup the committers identity.
#git config --global user.email "sdk@temporal.io"
#git config --global user.name "Temporal CLI"
echo "${{ steps.get_user.outputs.git_name }}"
echo "${{ steps.get_user.outputs.git_email }}"
git config user.name "${{ steps.get_user.outputs.git_name }}"
git config user.email "${{ steps.get_user.outputs.git_email }}"
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 }}" --author ${{ github.actor }}
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"