|
| 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: Create GitHub App Token |
| 41 | + uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf |
| 42 | + id: app-token |
| 43 | + with: |
| 44 | + app-id: ${{ vars.GH_APP_KONG_DOCS_ID }} |
| 45 | + private-key: ${{ secrets.GH_APP_KONG_DOCS_SECRET }} |
| 46 | + owner: Kong |
| 47 | + |
| 48 | + - name: Checkout developer.konghq.com |
| 49 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 |
| 50 | + with: |
| 51 | + token: ${{ steps.app-token.outputs.token }} |
| 52 | + |
| 53 | + - name: Setup Node.js |
| 54 | + uses: actions/setup-node@3235b876344d2a9aa001b8d1453c930bba69e610 # v3 |
| 55 | + with: |
| 56 | + node-version: '18' |
| 57 | + cache: 'npm' |
| 58 | + cache-dependency-path: tools/kong-conf-to-json/package-lock.json |
| 59 | + |
| 60 | + - name: Install kong-conf-to-json dependencies |
| 61 | + run: | |
| 62 | + cd tools/kong-conf-to-json |
| 63 | + npm ci |
| 64 | +
|
| 65 | + - name: Checkout kong-ee repository |
| 66 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 |
| 67 | + with: |
| 68 | + repository: 'Kong/kong-ee' |
| 69 | + token: ${{ steps.app-token.outputs.token }} |
| 70 | + path: 'kong-ee' |
| 71 | + ref: ${{ inputs.kong_ee_branch }} |
| 72 | + |
| 73 | + - name: Create kong-conf data directory |
| 74 | + run: | |
| 75 | + mkdir -p app/_data/kong-conf |
| 76 | +
|
| 77 | + - name: Generate kong.conf JSON |
| 78 | + run: | |
| 79 | + cd tools/kong-conf-to-json |
| 80 | + node run.js --file="../../kong-ee/${{ inputs.kong_conf_path }}" --version="${{ inputs.version }}" |
| 81 | +
|
| 82 | + - name: Generate index file |
| 83 | + run: | |
| 84 | + cd tools/kong-conf-to-json |
| 85 | + node index-file.js |
| 86 | +
|
| 87 | + - name: Check for changes |
| 88 | + id: changes |
| 89 | + run: | |
| 90 | + if git diff --quiet; then |
| 91 | + echo "changed=false" >> $GITHUB_OUTPUT |
| 92 | + else |
| 93 | + echo "changed=true" >> $GITHUB_OUTPUT |
| 94 | + fi |
| 95 | +
|
| 96 | + - name: Create pull request |
| 97 | + if: steps.changes.outputs.changed == 'true' |
| 98 | + uses: peter-evans/create-pull-request@22a9089034f40e5a961c8808d113e2c98fb63676 # v7 |
| 99 | + with: |
| 100 | + title: Generate Kong configuration JSON for version ${{ inputs.version }} |
| 101 | + commit-message: Generate Kong configuration JSON for version ${{ inputs.version }} |
| 102 | + body: | |
| 103 | + **Changes:** |
| 104 | + - Generated JSON representation of kong.conf file |
| 105 | + - Updated kong-conf index file with version information |
| 106 | + - Processed Kong version ${{ inputs.version }} |
| 107 | +
|
| 108 | + labels: skip-changelog,review:general |
| 109 | + token: ${{ steps.app-token.outputs.token }} |
| 110 | + branch: auto/generate-kong-conf-json-${{ github.run_number }} |
| 111 | + base: ${{ inputs.dev_site_base_branch }} |
| 112 | + add-paths: | |
| 113 | + app/** |
| 114 | +
|
| 115 | + - name: No changes detected |
| 116 | + if: steps.changes.outputs.changed == 'false' |
| 117 | + run: | |
| 118 | + echo "No changes detected in the kong-conf JSON files. No pull request will be created." |
0 commit comments