-
Notifications
You must be signed in to change notification settings - Fork 4.8k
138 lines (119 loc) · 4.87 KB
/
autodocs.yml
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
130
131
132
133
134
135
136
137
138
name: Autodocs
on:
workflow_dispatch:
inputs:
version:
description: "Version (e.g. 2.4.x)"
required: true
source_branch:
description: "Source Branch in kong/kong (e.g. release/2.4.x)"
required: true
target_branch:
description: "Target Branch in kong/docs.konghq.com (e.g. release/2.4)"
required: true
force_build:
description: "Ignore the build cache and build dependencies from scratch"
type: boolean
default: false
jobs:
build:
name: Build dependencies
runs-on: ubuntu-22.04
env:
DOWNLOAD_ROOT: $HOME/download-root
steps:
- name: Set environment variables
run: |
echo "INSTALL_ROOT=$HOME/install-root" >> $GITHUB_ENV
echo "DOWNLOAD_ROOT=$HOME/download-root" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$INSTALL_ROOT/openssl/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
- name: Checkout Kong source code
uses: actions/checkout@v4
- name: Lookup build cache
uses: actions/cache@v4
id: cache-deps
with:
path: ${{ env.INSTALL_ROOT }}
key: ${{ hashFiles('.ci/setup_env_github.sh') }}-${{ hashFiles('.requirements') }}-${{ hashFiles('kong-*.rockspec') }}
- name: Checkout kong-build-tools
if: steps.cache-deps.outputs.cache-hit != 'true' || github.event.inputs.force_build == 'true'
uses: actions/checkout@v4
with:
repository: Kong/kong-build-tools
path: kong-build-tools
ref: master
- name: Checkout go-pluginserver
if: steps.cache-deps.outputs.cache-hit != 'true' || github.event.inputs.force_build == 'true'
uses: actions/checkout@v4
with:
repository: Kong/go-pluginserver
path: go-pluginserver
- name: Add to Path
if: steps.cache-deps.outputs.cache-hit != 'true' || github.event.inputs.force_build == 'true'
run: echo "$INSTALL_ROOT/openssl/bin:$INSTALL_ROOT/openresty/nginx/sbin:$INSTALL_ROOT/openresty/bin:$INSTALL_ROOT/luarocks/bin:$GITHUB_WORKSPACE/kong-build-tools/openresty-build-tools" >> $GITHUB_PATH
- name: Install packages
if: steps.cache-deps.outputs.cache-hit != 'true' || github.event.inputs.force_build == 'true'
run: sudo apt update && sudo apt install libyaml-dev valgrind
- name: Build Kong dependencies
if: steps.cache-deps.outputs.cache-hit != 'true' || github.event.inputs.force_build == 'true'
run: |
source .ci/setup_env_github.sh
make dev
autodoc:
runs-on: ubuntu-22.04
needs: [build]
steps:
- name: Set environment variables
run: |
echo "INSTALL_ROOT=$HOME/install-root" >> $GITHUB_ENV
echo "DOWNLOAD_ROOT=$HOME/download-root" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$INSTALL_ROOT/openssl/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
- name: Checkout Kong source code
uses: actions/checkout@v4
with:
path: kong
ref: ${{ github.event.inputs.source_branch }}
- name: Checkout Kong Docs
uses: actions/checkout@v4
with:
repository: kong/docs.konghq.com
path: docs.konghq.com
token: ${{ secrets.PAT }}
ref: ${{ github.event.inputs.target_branch }}
- name: Lookup build cache
uses: actions/cache@v4
id: cache-deps
with:
path: ${{ env.INSTALL_ROOT }}
key: ${{ hashFiles('kong/.ci/setup_env_github.sh') }}-${{ hashFiles('kong/.requirements') }}-${{ hashFiles('kong/kong-*.rockspec') }}
- name: Add to Path
run: echo "$INSTALL_ROOT/openssl/bin:$INSTALL_ROOT/openresty/nginx/sbin:$INSTALL_ROOT/openresty/bin:$INSTALL_ROOT/luarocks/bin:$GITHUB_WORKSPACE/kong-build-tools/openresty-build-tools:$INSTALL_ROOT/go-pluginserver" >> $GITHUB_PATH
- name: Run Autodocs
run: |
cd kong
eval `luarocks path`
scripts/autodoc ../docs.konghq.com ${{ github.event.inputs.version }}
- name: Generate branch name
id: kong-branch
run: |
cd kong
output="$(git branch --show-current)"
echo "name=$output" >> $GITHUB_OUTPUT
- name: Show Docs status
run: |
cd docs.konghq.com
git status
git checkout -b "autodocs-${{ steps.kong-branch.outputs.name }}"
- name: Commit autodoc changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
repository: "./docs.konghq.com"
commit_message: "Autodocs update"
branch: "autodocs-${{ steps.kong-branch.outputs.name }}"
skip_fetch: true
push_options: "--force"
- name: Raise PR
run: |
cd docs.konghq.com
echo "${{ secrets.PAT }}" | gh auth login --with-token
gh pr create --base "${{ github.event.inputs.target_branch }}" --fill --label "review:autodoc"