Update README.md #25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Stage changes for Kong | |
on: | |
push: | |
branches: | |
- main | |
- workflow/** | |
paths-ignore: | |
- 'PRD/**' | |
- 'platform/kong/.generated/kong.yaml' | |
jobs: | |
# this job is useful to debug workflows, see https://github.com/mheap/debug-artifact | |
# debug-artifacts: | |
# name: Upload Debug Artifacts | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: Upload Debug Artifacts | |
# uses: mheap/debug-artifact@v1 | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
has-changes: | |
name: Have specs, configurations, or pipeline files changed | |
runs-on: ubuntu-latest | |
outputs: | |
are-changes: ${{ steps.changed-files.outputs.files }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- uses: dorny/paths-filter@v2 | |
id: changed-files | |
with: | |
filters: | | |
files: | |
- '.github/workflows/stage-changes-for-kong.yaml' | |
- 'flight-data/flights/openapi.yaml' | |
- 'flight-data/flights/kong/**' | |
- 'flight-data/routes/openapi.yaml' | |
- 'flight-data/routes/kong/**' | |
- 'sales/bookings/opeanapi.yaml' | |
- 'sales/bookings/kong/**' | |
- 'sales/customer/opeanapi.yaml' | |
- 'sales/customer/kong/**' | |
- 'platform/kong/**' | |
oas-to-kong: | |
name: Convert OAS to Kong configurations | |
needs: has-changes | |
if: ${{ needs.has-changes.outputs.are-changes == 'true' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup kced | |
uses: rspurgeon/setup-kced@v1 | |
with: | |
kced-version: '0.1.12' | |
wrapper: false | |
- name: Convert Flights API to Kong | |
# In two steps, convert the OpenAPI Spec to a Kong declarative configuration | |
# and then patch the result with the data in the kong/patches.yaml | |
run: | | |
kced openapi2kong -s flight-data/flights/openapi.yaml | kced patch -o .github/artifacts/kong/flight-data-flights-kong.yaml flight-data/flights/kong/patches.yaml | |
- name: Convert Routes API to Kong | |
# In two steps, convert the OpenAPI Spec to a Kong declarative configuration | |
# and then patch the result with the data in the kong/patches.yaml | |
run: | | |
kced openapi2kong -s flight-data/routes/openapi.yaml | kced patch -o .github/artifacts/kong/flight-data-routes-kong.yaml flight-data/routes/kong/patches.yaml | |
- name: Convert Bookings API to Kong | |
# In two steps, convert the OpenAPI Spec to a Kong declarative configuration | |
# and then patch the result with the data in the kong/patches.yaml | |
run: | | |
kced openapi2kong -s sales/bookings/openapi.yaml | kced patch -o .github/artifacts/kong/sales-bookings-kong.yaml sales/bookings/kong/patches.yaml | |
- name: Convert Customers API to Kong | |
# In two steps, convert the OpenAPI Spec to a Kong declarative configuration | |
# and then patch the result with the data in the kong/patches.yaml | |
run: | | |
kced openapi2kong -s sales/customer/openapi.yaml | kced patch -o .github/artifacts/kong/sales-customer-kong.yaml sales/customer/kong/patches.yaml | |
- name: Combine Kong Configurations | |
# Combine all the previous OAS->Kong configurations into one and put it in a well known place | |
run: | | |
kced merge .github/artifacts/kong/*-kong.yaml -o .github/artifacts/kong/kong-combined.yaml | |
- name: Platform Team Kong Additions | |
# The platform team has their own things to add to the final Kong configuration | |
# The platform/kong/.generated/kong.yaml is the final product and is stored in the repository | |
# Storing the generated file in the repo is intentional, it should help with PR reviews, transparency, and debugging | |
run: | | |
kced merge .github/artifacts/kong/kong-combined.yaml platform/kong/plugins/* platform/kong/vaults/* | kced patch -o platform/kong/.generated/kong.yaml platform/kong/patches.yaml | |
- name: Upload Artifacts | |
# Artifacts are the files that are built along the way of the pipeline but are not committed to the repo | |
uses: actions/upload-artifact@v3 | |
with: | |
name: kong-configurations | |
path: .github/artifacts/kong/*.yaml | |
- name: Create PR for changed Kong Gateway Configuration | |
# The only file that should be changed for this PR is platform/kong/.generated/kong.yaml | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
title: Stage Kong Gateway Configuration |