Skip to content

Trigger Client SDK Generation #481

Trigger Client SDK Generation

Trigger Client SDK Generation #481

name: Trigger Client SDK Generation
on:
workflow_dispatch:
inputs:
reason:
description: 'Reason for triggering client generation'
required: false
default: 'Manual trigger'
type: string
workflow_run:
workflows: ['Transform OpenAPI Specs']
types:
- completed
branches:
- main
permissions:
contents: read
jobs:
check:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
outputs:
should_trigger: ${{ steps.determine.outputs.should_trigger }}
steps:
# When triggered by workflow_run, check if transform.yml actually committed changes.
# We detect this by looking for the "Generated-by:" identifier in the commit body.
# NOTE: This identifier is defined in transform.yml - if you change it there,
# update the check here accordingly.
- name: Determine if client generation should run
id: determine
env:
GH_TOKEN: ${{ github.token }}
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "Manually triggered: ${{ github.event.inputs.reason }}"
echo "should_trigger=true" >> $GITHUB_OUTPUT
exit 0
fi
echo "Automatically triggered after successful Transform OpenAPI Specs workflow"
EXPECTED_IDENTIFIER="Generated-by: .github/workflows/transform.yml"
LAST_COMMIT=$(gh api repos/${{ github.repository }}/commits/main --jq '.commit.message')
echo "::group::Commit check details"
echo "Expected identifier: $EXPECTED_IDENTIFIER"
echo "Last commit message:"
echo "$LAST_COMMIT"
echo "::endgroup::"
if [[ "$LAST_COMMIT" == *"$EXPECTED_IDENTIFIER"* ]]; then
echo "should_trigger=true" >> $GITHUB_OUTPUT
echo "Transform committed changes, proceeding with client generation"
else
echo "should_trigger=false" >> $GITHUB_OUTPUT
echo "::notice::Skipping client generation - no meaningful spec changes were committed"
fi
trigger-clients:
runs-on: ubuntu-latest
needs: check
if: needs.check.outputs.should_trigger == 'true'
steps:
- name: Trigger Python Client SDK Generation
uses: actions/github-script@v7
with:
github-token: ${{ secrets.CLIENT_GENERATION_TOKEN }}
script: |
const result = await github.rest.actions.createWorkflowDispatch({
owner: 'gleanwork',
repo: 'api-client-python',
workflow_id: 'sdk_generation.yaml',
ref: 'main',
inputs: {}
});
console.log('Python client generation triggered:', result.status);
- name: Trigger TypeScript Client SDK Generation
uses: actions/github-script@v7
with:
github-token: ${{ secrets.CLIENT_GENERATION_TOKEN }}
script: |
const result = await github.rest.actions.createWorkflowDispatch({
owner: 'gleanwork',
repo: 'api-client-typescript',
workflow_id: 'sdk_generation.yaml',
ref: 'main',
inputs: {}
});
console.log('TypeScript client generation triggered:', result.status);
- name: Trigger Go Client SDK Generation
uses: actions/github-script@v7
with:
github-token: ${{ secrets.CLIENT_GENERATION_TOKEN }}
script: |
const result = await github.rest.actions.createWorkflowDispatch({
owner: 'gleanwork',
repo: 'api-client-go',
workflow_id: 'sdk_generation.yaml',
ref: 'main',
inputs: {}
});
console.log('Go client generation triggered:', result.status);
- name: Trigger Java Client SDK Generation
uses: actions/github-script@v7
with:
github-token: ${{ secrets.CLIENT_GENERATION_TOKEN }}
script: |
const result = await github.rest.actions.createWorkflowDispatch({
owner: 'gleanwork',
repo: 'api-client-java',
workflow_id: 'sdk_generation.yaml',
ref: 'main',
inputs: {}
});
console.log('Java client generation triggered:', result.status);
- name: Summary
run: |
echo "✅ All client SDK generation workflows have been triggered successfully!"
echo ""
echo "Triggered workflows:"
echo "- Python: https://github.com/gleanwork/api-client-python/actions"
echo "- TypeScript: https://github.com/gleanwork/api-client-typescript/actions"
echo "- Go: https://github.com/gleanwork/api-client-go/actions"
echo "- Java: https://github.com/gleanwork/api-client-java/actions"