-
Notifications
You must be signed in to change notification settings - Fork 323
129 lines (113 loc) · 4.79 KB
/
Copy pathupdate-cli-docs.yml
File metadata and controls
129 lines (113 loc) · 4.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: 'CLI Docs Update'
on:
workflow_dispatch:
inputs:
cli_release_tag:
description: 'Release tag from the CLI repo to update docs from'
required: true
commit_author:
description: 'Name to use for the commit author'
required: true
commit_author_email:
description: 'Email to use for the commit author'
required: true
commit_message:
description: 'Commit message for the docs update'
required: true
jobs:
update:
name: 'Pull changes from the CLI repo and update CLI docs'
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@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
app-id: ${{ secrets.TEMPORAL_CICD_APP_ID }}
private-key: ${{ secrets.TEMPORAL_CICD_PRIVATE_KEY }}
- name: Checkout docs repo
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: true
token: ${{ steps.generate_token.outputs.token }}
path: docs
ref: main
- name: Checkout CLI repo
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
path: cli
ref: ${{ github.event.inputs.cli_release_tag }}
submodules: recursive
persist-credentials: true
token: ${{ steps.generate_token.outputs.token }}
repository: temporalio/cli
- name: Setup Go
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version: '1.26'
- name: Checkout cloud-cli repo
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
path: cloud-cli
submodules: recursive
persist-credentials: true
token: ${{ steps.generate_token.outputs.token }}
repository: temporalio/cloud-cli
- name: Generate CLI docs
working-directory: cli
# Gen-docs runs twice: main CLI and cloud CLI have overlapping option
# sets ("client", "common"), so combining them in one invocation causes
# a "duplicate option set" error. The second run uses -subdir to place
# cloud subcommands into a cloud/ subdirectory.
run: |
go run ./cmd/gen-docs -input internal/temporalcli/commands.yaml -input cliext/option-sets.yaml -output dist/docs
go run ./cmd/gen-docs -input ../cloud-cli/temporalcloudcli/commands.yml -output dist/docs -subdir cloud
- name: Copy generated command reference into the docs repo
working-directory: docs
run: |
set -ex
# Regenerate the command reference pages. cp -R preserves the cloud/
# subdirectory produced by -subdir.
rm -rf docs/cli/command-reference
mkdir -p docs/cli/command-reference
cp -R ../cli/dist/docs/* docs/cli/command-reference/
# gen-docs intentionally does not emit index.mdx landing pages: those
# are hand-maintained (custom ordering, embedded components such as
# ReleaseNoteHeader). Restore them after regeneration so they are not
# lost by the rm -rf above.
git checkout HEAD -- docs/cli/command-reference/index.mdx
git checkout HEAD -- docs/cli/command-reference/cloud/index.mdx
- name: Post-process generated CLI docs
working-directory: docs
# Injects the ReleaseNoteHeader banner into cloud CLI pages and keeps
# command-reference/index.mdx and sidebars.js in sync with the
# generated commands. Not previously called from this workflow.
run: node bin/post-process-cli-docs.js
- name: Publish generated docs to documentation repo
env:
GH_TOKEN: ${{ github.token }}
COMMIT_AUTHOR: ${{ github.event.inputs.commit_author }}
COMMIT_AUTHOR_EMAIL: ${{ github.event.inputs.commit_author_email }}
CLI_RELEASE_TAG: ${{ github.event.inputs.cli_release_tag }}
COMMIT_MESSAGE: ${{ github.event.inputs.commit_message }}
working-directory: docs
run: |
set -ex
git config user.name "$COMMIT_AUTHOR"
git config user.email "$COMMIT_AUTHOR_EMAIL"
branch_name="update-cli-docs-$CLI_RELEASE_TAG"
git checkout -b "$branch_name"
git add -A docs/cli/command-reference
git commit -m "$COMMIT_MESSAGE"
git push origin "$branch_name"
gh pr create \
--body "Autogenerated PR from https://github.com/temporalio/cli" \
--title "$COMMIT_MESSAGE" \
--head "$branch_name" \
--base "main"