Skip to content

Latest commit

 

History

History
115 lines (95 loc) · 4.01 KB

README.md

File metadata and controls

115 lines (95 loc) · 4.01 KB

Githut Action

Important Info

  • name: compile_openapi
  • yaml reference: Auddia/cicd/actions/compile_openapi@<tag>
  • action type: Docker Action

Description

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.

Tags

This action is available on tags v0 and above

openapi made available in the following step/action types

  • 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)
  • Other action types not tested

Required Setup

To use this action in your repository you need to setup the following templating structure.

  1. 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.
  2. Create a template.yaml file

Example template.yaml

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'
  1. Utilize a directory hierarchy to control the templates yaml references.
  2. Utilize the environment_key and environment_value inputs to dynamically update the imports in the template. This is primarily used to switch the environment for separate build configurations

Example Structure

Input Arguments

openapi_dir
  • Description: The directory location of all the openapi templates and configurations
  • type: string
  • default: ./
template
  • Description: The name of the template yaml file
  • type: string
  • default: template.yaml
outfile
  • Description: The name of the outputted Open API file.
  • type: string
  • default: openapi.yaml
environment_key
  • Description: Key in the template to replace with the environment value.
  • type: string
  • default: <environment>
environment_value
  • Description: Value that will replace the environment key in the template.
  • type: string
  • default: production

Example Usage

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 }}

Additonal Usage