- name:
compile_openapi
- yaml reference:
Auddia/cicd/actions/compile_openapi@<tag>
- action type: Docker Action
This action utilizes the swagger-cli and the templating structure outlined above to automatically build an openapi.yaml
file for tools that
need the openapi configuration (i.e. conficure_ gcp_endpoints
). The configuration generated in this action is available to other actions/steps in the same job.
This action is available on tags v0
and above
- Composite Actions
- The data maybe in a wierd (i.e. non-default directory but it is there)
- Docker Actions
- Tested image:
google/cloud-sdk
- The data maybe in a wierd (i.e. non-default directory but it is there)
- Tested image:
- Other action types not tested
To use this action in your repository you need to setup the following templating structure.
- Create a directory to store all the open api data/definitions. Make a note of this dir because it will be the value used for the
opeanapi_dir
argument to the action. - Create a
template.yaml
file
swagger: "2.0"
info:
title:
$ref: './<environment>/config.yaml#/info/title'
description:
$ref: './<environment>/config.yaml#/info/description'
version:
$ref: './<environment>/config.yaml#/versions/api-version'
schemes:
- https
produces:
- application/json
host:
$ref: './<environment>/config.yaml#/environment/host'
x-google-endpoints:
$ref: './<environment>/config.yaml#/environment/x-google-endpoints'
x-google-backend:
$ref: './<environment>/config.yaml#/environment/x-google-backend'
securityDefinitions:
# This section configures basic authentication with an API key.
api_key:
type: "apiKey"
name: "key"
in: "query"
security:
- api_key: [ ]
paths:
$ref: './common/endpoints.yaml#/paths'
- Utilize a directory hierarchy to control the templates yaml references.
- Utilize the
environment_key
andenvironment_value
inputs to dynamically update the imports in the template. This is primarily used to switch the environment for separate build configurations
- Description: The directory location of all the openapi templates and configurations
type
:string
default
:./
- Description: The name of the template yaml file
type
:string
default
:template.yaml
- Description: The name of the outputted Open API file.
type
:string
default
:openapi.yaml
- Description: Key in the template to replace with the environment value.
type
:string
default
:<environment>
- Description: Value that will replace the environment key in the template.
type
:string
default
:production
jobs:
example job:
name: 'Configure GCP Endpoints Example'
runs-on: ubuntu-latest
steps:
- name: Compile OpenAPI YAML File
uses: Auddia/cicd/actions/compile_openapi@<tag>
with:
openapi_dir: ${{ inputs.openapi_dir }}
template: ${{ inputs.template }}
outfile: ${{ inputs.openapi_yaml }}
environment_key: ${{ inputs.environment_key }}
environment_value: ${{ inputs.environment_value }}