-
Notifications
You must be signed in to change notification settings - Fork 150
111 lines (93 loc) · 5.92 KB
/
k8s_apis_sync.yaml
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
name: k8s_apis_sync
on:
workflow_dispatch:
inputs:
release:
type: string
required: true
description: ''
bucket_folder:
type: string
required: true
description: ''
jobs:
k8s_apis_sync:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
actions: write
steps:
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.DOCS_APP_ID }}
private-key: ${{ secrets.DOCS_APP_PRIVATE_KEY }}
- name: 'Checkout'
uses: actions/checkout@v3
with:
token: ${{ steps.generate-token.outputs.token }}
- name: 'Install crdoc'
run: |-
curl -LO https://github.com/fybrik/crdoc/releases/download/v0.6.3/crdoc_Linux_x86_64.tar.gz
tar -xvzf crdoc_Linux_x86_64.tar.gz
sudo mv crdoc /bin/crdoc
- name: 'Fetch release'
run: |-
RELEASE="${{ github.event.inputs.release }}"
BUCKET_FOLDER="${{ github.event.inputs.bucket_folder }}"
aws s3 cp "s3://redislabs-k8s/${BUCKET_FOLDER}/redis-enterprise-operator-${RELEASE}.tar.gz" --no-sign-request . --region us-east-1
tar xf "redis-enterprise-operator-${RELEASE}.tar.gz"
- name: 'Generate READMEs'
run: |-
mkdir artifacts
mkdir templates
cp content/operate/kubernetes/reference/kubernetes-api-reference-template.tmpl templates/template.tmpl
crdoc --resources crds/reaadb_crd.yaml --output artifacts/redis_enterprise_active_active_database_api.md --template templates/template.tmpl
sed -E -i 's/^### RedisEnterpriseActiveActiveDatabase\./### /g' artifacts/redis_enterprise_active_active_database_api.md
sed -E -i 's/^<sup><sup>\[↩ Parent\]\(#redisenterpriseactiveactivedatabase/<sup><sup>\[↩ Parent\]\(#/g' artifacts/redis_enterprise_active_active_database_api.md
sed -E -i 's/<td><a href="#redisenterpriseactiveactivedatabase/<td><a href="#/' artifacts/redis_enterprise_active_active_database_api.md
sed -E -i 's/\[index\]/\[\]/g' artifacts/redis_enterprise_active_active_database_api.md
awk '/(#[^")]+)index/ {gsub(/index/,"")}; {print}' artifacts/redis_enterprise_active_active_database_api.md > _tmp.md && mv _tmp.md artifacts/redis_enterprise_active_active_database_api.md
crdoc --resources crds/rec_crd.yaml --output artifacts/redis_enterprise_cluster_api.md --template templates/template.tmpl
sed -E -i 's/^### RedisEnterpriseCluster\./### /g' artifacts/redis_enterprise_cluster_api.md
sed -E -i 's/^<sup><sup>\[↩ Parent\]\(#redisenterprisecluster/<sup><sup>\[↩ Parent\]\(#/g' artifacts/redis_enterprise_cluster_api.md
sed -E -i 's/<td><a href="#redisenterprisecluster/<td><a href="#/' artifacts/redis_enterprise_cluster_api.md
sed -E -i 's/\[index\]/\[\]/g' artifacts/redis_enterprise_cluster_api.md
awk '/(#[^")]+)index/ {gsub(/index/,"")}; {print}' artifacts/redis_enterprise_cluster_api.md > _tmp.md && mv _tmp.md artifacts/redis_enterprise_cluster_api.md
crdoc --resources crds/redb_crd.yaml --output artifacts/redis_enterprise_database_api.md --template templates/template.tmpl
sed -E -i 's/^### RedisEnterpriseDatabase\./### /g' artifacts/redis_enterprise_database_api.md
sed -E -i 's/^<sup><sup>\[↩ Parent\]\(#redisenterprisedatabase/<sup><sup>\[↩ Parent\]\(#/g' artifacts/redis_enterprise_database_api.md
sed -E -i 's/<td><a href="#redisenterprisedatabase/<td><a href="#/' artifacts/redis_enterprise_database_api.md
sed -E -i 's/\[index\]/\[\]/g' artifacts/redis_enterprise_database_api.md
awk '/(#[^")]+)index/ {gsub(/index/,"")}; {print}' artifacts/redis_enterprise_database_api.md > _tmp.md && mv _tmp.md artifacts/redis_enterprise_database_api.md
crdoc --resources crds/rerc_crd.yaml --output artifacts/redis_enterprise_remote_cluster_api.md --template templates/template.tmpl
sed -E -i 's/^### RedisEnterpriseRemoteCluster\./### /g' artifacts/redis_enterprise_remote_cluster_api.md
sed -E -i 's/^<sup><sup>\[↩ Parent\]\(#redisenterpriseremotecluster/<sup><sup>\[↩ Parent\]\(#/g' artifacts/redis_enterprise_remote_cluster_api.md
sed -E -i 's/<td><a href="#redisenterpriseremotecluster/<td><a href="#/' artifacts/redis_enterprise_remote_cluster_api.md
sed -E -i 's/\[index\]/\[\]/g' artifacts/redis_enterprise_remote_cluster_api.md
awk '/(#[^")]+)index/ {gsub(/index/,"")}; {print}' artifacts/redis_enterprise_remote_cluster_api.md > _tmp.md && mv _tmp.md artifacts/redis_enterprise_remote_cluster_api.md
- name: 'Send pull request'
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |-
RELEASE="${{ github.event.inputs.release }}"
BRANCH="k8s_apis_docs_${RELEASE}"
# Setup git email and username
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git checkout -b "${BRANCH}"
cp artifacts/redis_enterprise_active_active_database_api.md content/operate/kubernetes/reference/
cp artifacts/redis_enterprise_cluster_api.md content/operate/kubernetes/reference/
cp artifacts/redis_enterprise_database_api.md content/operate/kubernetes/reference/
cp artifacts/redis_enterprise_remote_cluster_api.md content/operate/kubernetes/reference/
git apply content/operate/kubernetes/reference/kubernetes-api-reference-frontmatter.patch
git add content/operate/kubernetes/reference/
git commit -m "k8s api docs ${RELEASE}"
git push origin "${BRANCH}"
gh pr create \
--body "k8s api docs ${RELEASE}" \
--title "k8s api docs ${RELEASE}" \
--head "$BRANCH" \
--base "main"