1+ name : Generate Kong Configuration JSON
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ version :
7+ description : ' Kong version to generate config for (e.g., 3.9)'
8+ required : true
9+ type : string
10+ kong_ee_branch :
11+ description : ' Branch to use from kong-ee repository'
12+ required : true
13+ default : ' main'
14+ type : string
15+ dev_site_base_branch :
16+ description : ' Dev site base branch, e.g. main'
17+ required : true
18+ type : string
19+ kong_conf_path :
20+ description : ' Path to kong.conf file in kong-ee repo (relative to repo root)'
21+ required : false
22+ default : ' kong.conf.default'
23+ type : string
24+
25+ permissions :
26+ contents : write
27+ pull-requests : write
28+
29+ jobs :
30+ generate-kong-conf-json :
31+ name : Generate Kong Configuration JSON
32+ runs-on : ubuntu-latest
33+ timeout-minutes : 20
34+ steps :
35+ - name : Harden Runner
36+ uses : step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
37+ with :
38+ egress-policy : audit
39+
40+ - name : Checkout developer.konghq.com
41+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
42+ with :
43+ token : ${{ secrets.PAT }}
44+
45+ - name : Setup Node.js
46+ uses : actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
47+ with :
48+ node-version : ' 18'
49+ cache : ' npm'
50+ cache-dependency-path : tools/kong-conf-to-json/package-lock.json
51+
52+ - name : Install kong-conf-to-json dependencies
53+ run : |
54+ cd tools/kong-conf-to-json
55+ npm ci
56+
57+ - name : Checkout kong-ee repository
58+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
59+ with :
60+ repository : ' Kong/kong-ee'
61+ token : ${{ secrets.PAT }}
62+ path : ' kong-ee'
63+ ref : ${{ inputs.kong_ee_branch }}
64+
65+ - name : Create kong-conf data directory
66+ run : |
67+ mkdir -p app/_data/kong-conf
68+
69+ - name : Generate kong.conf JSON
70+ run : |
71+ cd tools/kong-conf-to-json
72+ node run.js --file="../../kong-ee/${{ inputs.kong_conf_path }}" --version="${{ inputs.version }}"
73+
74+ - name : Generate index file
75+ run : |
76+ cd tools/kong-conf-to-json
77+ node index-file.js
78+
79+ - name : Check for changes
80+ id : changes
81+ run : |
82+ if git diff --quiet; then
83+ echo "changed=false" >> $GITHUB_OUTPUT
84+ else
85+ echo "changed=true" >> $GITHUB_OUTPUT
86+ fi
87+
88+ - name : Create pull request
89+ if : steps.changes.outputs.changed == 'true'
90+ uses : peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7
91+ with :
92+ title : Generate Kong configuration JSON for version ${{ inputs.version }}
93+ commit-message : Generate Kong configuration JSON for version ${{ inputs.version }}
94+ body : |
95+ **Changes:**
96+ - Generated JSON representation of kong.conf file
97+ - Updated kong-conf index file with version information
98+ - Processed Kong version ${{ inputs.version }}
99+
100+ labels : skip-changelog,review:general
101+ token : ${{ secrets.PAT }}
102+ branch : auto/generate-kong-conf-json-${{ github.run_number }}
103+ base : ${{ inputs.dev_site_base_branch }}
104+
105+ - name : No changes detected
106+ if : steps.changes.outputs.changed == 'false'
107+ run : |
108+ echo "No changes detected in the kong-conf JSON files. No pull request will be created."
0 commit comments