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