Decouple api generation flow from docker build (#62)

* decouple api generation from docker build

* add different PAT
This commit is contained in:
pascal-fischer
2023-06-12 14:47:20 +02:00
committed by GitHub
parent 44f2a02a25
commit d18f5c076f
2 changed files with 44 additions and 36 deletions

View File

@@ -3,46 +3,11 @@ on:
push:
branches:
- main
tags:
- "**"
workflow_dispatch:
inputs:
generateAPI:
description: 'Generates API pages if set'
required: false
default: false
type: boolean
jobs:
generate_api_pages:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Install swagger-codegen
if: ${{ inputs.generateAPI }}
run: brew install swagger-codegen
- name: Generate api pages for netbird main openapi definition
if: ${{ inputs.generateAPI }}
run: |
npm install
npm run gen
- name: Commit and push changes
if: ${{ inputs.generateAPI }}
run: |
git config --global user.email "no-reply@github.com"
git config --global user.name "GitHub Actions"
git add -A
git commit -m "Update API pages"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git push
docs_build_n_push:
runs-on: ubuntu-latest
needs: [generate_api_pages]
steps:
- uses: actions/checkout@v2
-
name: Docker meta
id: meta

View File

@@ -0,0 +1,43 @@
name: generate api pages
on:
workflow_dispatch:
inputs:
tag:
description: 'Netbird release tag version'
required: true
default: "refs/tags/vX.Y.Z"
type: string
jobs:
generate_api_pages:
runs-on: macos-latest
steps:
- name: Parse tag input
id: semver_parser
uses: booxmedialtd/ws-action-parse-semver@v1
with:
input_string: ${{ github.event.inputs.tag }}
version_extractor_regex: '\/v(.*)$'
- uses: actions/checkout@v2
- name: Install swagger-codegen
if: ${{ inputs.generateAPI }}
run: brew install swagger-codegen
- name: Generate api pages for netbird main openapi definition
if: ${{ inputs.generateAPI }}
run: |
swagger-codegen generate -i https://raw.githubusercontent.com/netbirdio/netbird/v${{ steps.semver_parser.outputs.fullversion }}/management/server/http/api/openapi.yml -l openapi -o generator/openapi
npx ts-node generator/index.ts gen --input generator/openapi/openapi.json --output src/pages/ipa/resources
- name: Commit and push changes
if: ${{ inputs.generateAPI }}
run: |
git config --global user.email "no-reply@github.com"
git config --global user.name "GitHub Actions"
git add -A
git commit -m "Update API pages"
git remote set-url origin https://x-access-token:${{ secrets.DEV_GITHUB_TOKEN }}@github.com/${{ github.repository }}
git push