-
Notifications
You must be signed in to change notification settings - Fork 88
103 lines (87 loc) · 3.15 KB
/
ci.yaml
File metadata and controls
103 lines (87 loc) · 3.15 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
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"
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 }}"
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"