Auto generate and publish CLI docs on each release #842
This file contains hidden or 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: Continuous Integration | |
| on: | |
| pull_request: | |
| workflow_dispatch: | |
| release: | |
| types: [published] | |
| jobs: | |
| update: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: 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: Publish generated docs to documentation repo | |
| env: | |
| GH_TOKEN: ${{ github.generate_token.outputs.token }} | |
| run: | | |
| set -e | |
| set -x | |
| curl -H "Authorization: token ${{ steps.generate_token.outputs.token }}" https://api.github.com/user | |
| 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" | |
| # 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" |