Skip to content

Update SDK code samples #4

Update SDK code samples

Update SDK code samples #4

Workflow file for this run

name: Update SDK code samples
on:
workflow_dispatch:
inputs:
schema_url:
description: 'URL of the base OpenAPI schema'
required: true
default: 'https://api.polar.sh/openapi.json'
languages:
description: 'Comma-separated list of languages to generate code samples for'
required: true
default: 'python,js'
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ github.workspace }}/sdk
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Speakeasy CLI
run: |
curl -fsSL https://raw.githubusercontent.com/speakeasy-api/speakeasy/main/install.sh | sh
- name: Download schema and convert to YAML
working-directory: ${{ github.workspace }}/
run: |
curl -o source.json ${{ github.event.inputs.schema_url }}
cat source.json | yq -P > source.yml
- name: Download code samples overlays and combine them
run: |
IFS=',' read -r -a languages <<< "${{ github.event.inputs.languages }}"
for lang in "${languages[@]}"; do
curl -o "codeSamples.${lang}.yml" "https://raw.githubusercontent.com/polarsource/polar-${lang}/main/codeSamples.yaml"
done
yq eval-all 'select(fileIndex == 0) as $first | .actions as $actions ireduce ({}; .actions += $actions) | .overlay = $first.overlay | .info = $first.info' codeSamples.* > overlay.yml
- name: Apply code samples overlay and convert to JSON
run: |
speakeasy overlay apply -s source.yml -o overlay.yml --out schema.yml
cat schema.yml | yq -o json > schema.json
- name: Commit and push changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Update code samples"
file_pattern: sdk/schema.json