Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/openapi-workflow-fixes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@scope3/agentic-client": patch
---

Update OpenAPI auto-update workflow to create PRs and fetch from agentic-api repo. Configure release workflow for npm Trusted Publishing with OIDC.
49 changes: 30 additions & 19 deletions .github/workflows/auto-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- name: Checkout code
Expand All @@ -33,20 +34,24 @@ jobs:
- name: Check for changes
id: git-check
run: |
git diff --exit-code src/types/ || echo "changed=true" >> $GITHUB_OUTPUT
git diff --exit-code src/types/ outcome-agent-openapi.yaml partner-api.yaml platform-api.yaml || echo "changed=true" >> $GITHUB_OUTPUT

- name: Commit and push if changed
- name: Create Pull Request
if: steps.git-check.outputs.changed == 'true'
run: |
# Configure git
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add src/types/ openapi.yaml media-agent-openapi.yaml

# Create a new branch
BRANCH_NAME="auto-update-openapi-$(date +%s)"
git checkout -b $BRANCH_NAME

# Commit type changes
git add src/types/ outcome-agent-openapi.yaml partner-api.yaml platform-api.yaml
git commit -m "chore: update types from OpenAPI spec"
git push

- name: Create changeset
if: steps.git-check.outputs.changed == 'true'
run: |
# Create changeset
cat << EOF > .changeset/auto-update-$(date +%s).md
---
"@scope3/agentic-client": patch
Expand All @@ -56,18 +61,24 @@ jobs:
EOF
git add .changeset/
git commit -m "chore: create changeset for type updates"
git push

- name: Version packages
if: steps.git-check.outputs.changed == 'true'
run: |
npx changeset version
git add .
git commit -m "chore: version packages"
git push
# Push branch
git push -u origin $BRANCH_NAME

- name: Build and publish
if: steps.git-check.outputs.changed == 'true'
run: npm run release
# Create PR using GitHub CLI
gh pr create \
--title "chore: auto-update types from OpenAPI spec" \
--body "This PR was automatically generated by the auto-update workflow.

## Changes
- Updated types from latest OpenAPI specifications from [agentic-api repo](https://github.com/scope3data/agentic-api/tree/main/mintlify)
- Outcome Agent API (replacing Media Agent)
- Partner API
- Platform API
- Created changeset for patch version bump

The types will be published once this PR is merged and the release workflow runs." \
--base main \
--head $BRANCH_NAME
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -40,4 +43,3 @@ jobs:
title: 'chore: version packages'
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
"lint": "eslint src --ext .ts",
"format": "prettier --write \"src/**/*.ts\"",
"type-check": "tsc --noEmit",
"generate-types": "openapi-typescript openapi.yaml -o src/types/api.ts",
"generate-media-agent-types": "openapi-typescript media-agent-openapi.yaml -o src/types/media-agent-api.ts",
"update-schemas": "curl -f -o openapi.yaml https://docs.agentic.scope3.com/openapi.yaml && curl -f -o media-agent-openapi.yaml https://docs.agentic.scope3.com/media-agent-openapi.yaml && npm run generate-types && npm run generate-media-agent-types",
"generate-outcome-agent-types": "openapi-typescript outcome-agent-openapi.yaml -o src/types/outcome-agent-api.ts",
"generate-partner-api-types": "openapi-typescript partner-api.yaml -o src/types/partner-api.ts",
"generate-platform-api-types": "openapi-typescript platform-api.yaml -o src/types/platform-api.ts",
"update-schemas": "curl -f -o outcome-agent-openapi.yaml https://raw.githubusercontent.com/scope3data/agentic-api/main/mintlify/outcome-agent-openapi.yaml && curl -f -o partner-api.yaml https://raw.githubusercontent.com/scope3data/agentic-api/main/mintlify/partner-api.yaml && curl -f -o platform-api.yaml https://raw.githubusercontent.com/scope3data/agentic-api/main/mintlify/platform-api.yaml && npm run generate-outcome-agent-types && npm run generate-partner-api-types && npm run generate-platform-api-types",
"prepare": "husky",
"pretest": "npm run type-check",
"changeset": "changeset",
Expand Down