Skip to content

Merge pull request #7 from DPS0340/main #5

Merge pull request #7 from DPS0340/main

Merge pull request #7 from DPS0340/main #5

Workflow file for this run

name: Save openapi.yaml as artifact
on:
push:
branches:
- main
permissions:
contents: write
id-token: write
pages: write
jobs:
save-and-upload-openapi-yaml:
runs-on: ubuntu-24.04
steps:
- name: checkout
uses: actions/checkout@v2
- name: Start minikube
uses: medyagh/setup-minikube@master
- name: Generate helm definitions
run: make helm
- name: Deploy helm
run: make helm-deploy
- name: Run kubectl proxy
run: nohup kubectl proxy &
- name: Fetch openapi.yaml
run: mkdir -p ./generated ; curl -k localhost:8001/openapi/v2 | yq -P > ./generated/openapi.yaml
- name: envsubst openapi.yaml
run: >
export paths=$(yq '.paths | with_entries(select(.key | test("pipeline")))' ./generated/openapi.yaml | sed 's/^/ /') ;
export definitions=$(yq '.definitions | with_entries(select(.key | (test("pipeline") or test("io.k8s.apimachinery"))))' ./generated/openapi.yaml | sed 's/^/ /') ;
rm -f ./generated/openapi.yaml ;
envsubst < ./generated/openapi.template.yaml > ./generated/openapi.yaml
- name: Upload openapi.yaml as artifact
uses: actions/upload-artifact@v4
with:
name: openapi.yaml
path: ./generated/openapi.yaml
if-no-files-found: error
- uses: actions/setup-node@v4
with:
node-version: 'latest'
registry-url: 'https://registry.npmjs.org'
- name: Compile redoc static pages
run: >
mkdir -p ./generated/docs ;
mkdir -p ./generated/docs/redoc ;
npx --node-options='--max-old-space-size=16384' @redocly/cli build-docs ./generated/openapi.yaml -o ./generated/docs/redoc/index.html
- name: Commit redoc static page definitions
uses: stefanzweifel/git-auto-commit-action@v5
- name: Upload GitHub Pages artifact
uses: actions/[email protected]
with:
path: ./generated/docs
deploy-github-pages:
runs-on: ubuntu-24.04
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: save-and-upload-openapi-yaml
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
generate-and-publish-sdks-to-npm:
runs-on: ubuntu-24.04
needs: save-and-upload-openapi-yaml
strategy:
max-parallel: 1
matrix:
sdk:
- type: typescript-axios
type-shorthand: ts-axios
- type: typescript-fetch
type-shorthand: ts-fetch
steps:
- name: checkout
uses: actions/checkout@v2
- uses: actions/setup-node@v4
with:
node-version: 'latest'
registry-url: 'https://registry.npmjs.org'
- name: Generate typescript-axios sdk using openapi.yaml
run: >
npx @openapitools/openapi-generator-cli generate
-i ./generated/openapi.yaml
-o ./generated/sdk/${{ matrix.sdk.type-shorthand }}-out
-g ${{ matrix.sdk.type }}
- name: Move sdk definitions into npm package using template
run: >
mkdir -p ./generated/sdk &&
rm -rf ./generated/sdk/${{ matrix.sdk.type-shorthand }} ;
cp -r ./template/sdk/${{ matrix.sdk.type-shorthand }} ./generated/sdk/${{ matrix.sdk.type-shorthand }} &&
mv ./generated/sdk/${{ matrix.sdk.type-shorthand }}-out/* ./generated/sdk/${{ matrix.sdk.type-shorthand }}-out/.* ./generated/sdk/${{ matrix.sdk.type-shorthand }} &&
rmdir ./generated/sdk/${{ matrix.sdk.type-shorthand }}-out
- name: Commit sdk definitions
uses: stefanzweifel/git-auto-commit-action@v5
- name: Publish ${{ matrix.sdk.type-shorthand }} sdk into npm
run: >
cd ./generated/sdk/${{ matrix.sdk.type-shorthand }} &&
npm publish --provenance --access public --tag ${{ github.sha }}
continue-on-error: true
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}