Document Foundry auto-deploy + optional OAuth registry login#21
Document Foundry auto-deploy + optional OAuth registry login#21anand-testcompare merged 2 commits intomainfrom
Conversation
Add a concise overview of the OpenAPI->functions import path with screenshots and cross-links from existing Foundry docs.
Allow publish workflow to mint a short-lived OAuth2 access token when client credentials are available, with a fallback to the existing FOUNDRY_TOKEN secret.
|
🚅 Deployed to the dspy-reference-examples-pr-21 environment in dspy-reference-example
|
WalkthroughThis PR introduces OAuth2-based authentication for Foundry registry workflows with fallback to legacy static tokens, alongside comprehensive documentation for the Foundry auto-deploy workflow that converts OpenAPI contracts into importable Foundry functions. Changes
Sequence Diagram(s)sequenceDiagram
participant GH as GitHub Actions
participant OAuth as OAuth Provider
participant Foundry as Foundry Registry
GH->>GH: Check for OAuth credentials<br/>(CLIENT_ID, CLIENT_SECRET)
alt OAuth Credentials Present
GH->>OAuth: Request access token<br/>(client_id, client_secret)
OAuth-->>GH: Return access_token (JSON)
GH->>GH: Parse & extract token<br/>from response
GH->>GH: Mask token in logs
GH->>Foundry: Login with OAuth token
else OAuth Credentials Absent
GH->>Foundry: Login with FOUNDRY_TOKEN<br/>(legacy path)
end
Foundry-->>GH: Authentication successful
GH->>Foundry: Publish artifacts
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@docs/foundry-auto-deploy.md`:
- Around line 68-70: Update the "Auth Notes" section to be consistent with
docs/deploy-ci.md by changing the guidance about FOUNDRY_TOKEN to indicate it is
a short-lived token that requires refreshing per publish window (instead of
recommending a long‑lived token), and add a preferred OAuth2 client credentials
option describing the required vars FOUNDRY_URL, FOUNDRY_OAUTH_CLIENT_ID, and
FOUNDRY_OAUTH_CLIENT_SECRET as the recommended CI auth method; keep the legacy
FOUNDRY_TOKEN paragraph as an alternative and advise creating a dedicated
non‑admin Foundry user with Edit permission if using it.
🧹 Nitpick comments (1)
.github/workflows/publish-foundry.yml (1)
136-147: Consider adding error handling for OAuth token response parsing.If the OAuth token endpoint returns a non-200 response or an unexpected JSON structure (e.g., missing
access_token), line 145 will fail with an unhelpfulKeyError. Adding defensive parsing would improve debuggability.♻️ Suggested improvement for error handling
token_json="$( - curl -fsS -X POST "${foundry_url}/multipass/api/oauth2/token" \ + curl -fsS --max-time 30 -X POST "${foundry_url}/multipass/api/oauth2/token" \ -H "Content-Type: application/x-www-form-urlencoded" \ --data-urlencode "grant_type=client_credentials" \ --data-urlencode "client_id=${FOUNDRY_OAUTH_CLIENT_ID}" \ --data-urlencode "client_secret=${FOUNDRY_OAUTH_CLIENT_SECRET}" \ "${scope_arg[@]}" )" - oauth_token="$(python -c 'import json,sys; print(json.loads(sys.stdin.read())["access_token"])' <<<"${token_json}")" + oauth_token="$(python -c ' +import json, sys +data = json.loads(sys.stdin.read()) +if "access_token" not in data: + print("Error: OAuth response missing access_token. Response:", data.get("error", data), file=sys.stderr) + sys.exit(1) +print(data["access_token"]) +' <<<"${token_json}")"This adds a 30-second timeout to prevent indefinite hangs and provides a clearer error message if the OAuth response is malformed or contains an error.
| ## Auth Notes | ||
|
|
||
| For CI, prefer a dedicated non-admin Foundry user that has **Edit** permission on the target Artifact Repository. Generate a long-lived token as that user and store it as the GitHub secret `FOUNDRY_TOKEN`. |
There was a problem hiding this comment.
Auth notes are inconsistent with other docs and missing OAuth2 option.
Two issues:
-
Inconsistency: This doc recommends a "long-lived token" for
FOUNDRY_TOKEN, butdocs/deploy-ci.md(line 62) statesFOUNDRY_TOKENis "short-lived" and needs refreshing before each publish window. -
Missing OAuth2 guidance: The workflow now supports OAuth2 client credentials as the preferred authentication method (via
FOUNDRY_URL,FOUNDRY_OAUTH_CLIENT_ID,FOUNDRY_OAUTH_CLIENT_SECRET), but this section only mentions the legacyFOUNDRY_TOKENapproach.
📝 Suggested update to align auth guidance
## Auth Notes
-For CI, prefer a dedicated non-admin Foundry user that has **Edit** permission on the target Artifact Repository. Generate a long-lived token as that user and store it as the GitHub secret `FOUNDRY_TOKEN`.
+For CI authentication, two options are available:
+
+1. **OAuth2 (preferred)**: Configure `FOUNDRY_URL`, `FOUNDRY_OAUTH_CLIENT_ID`, and `FOUNDRY_OAUTH_CLIENT_SECRET` secrets. The workflow mints a short-lived access token at runtime.
+
+2. **Legacy token**: Generate a token from a dedicated non-admin Foundry user with **Edit** permission on the target Artifact Repository. Store it as `FOUNDRY_TOKEN`. Note: This token is short-lived and must be refreshed before each publish window.🤖 Prompt for AI Agents
In `@docs/foundry-auto-deploy.md` around lines 68 - 70, Update the "Auth Notes"
section to be consistent with docs/deploy-ci.md by changing the guidance about
FOUNDRY_TOKEN to indicate it is a short-lived token that requires refreshing per
publish window (instead of recommending a long‑lived token), and add a preferred
OAuth2 client credentials option describing the required vars FOUNDRY_URL,
FOUNDRY_OAUTH_CLIENT_ID, and FOUNDRY_OAUTH_CLIENT_SECRET as the recommended CI
auth method; keep the legacy FOUNDRY_TOKEN paragraph as an alternative and
advise creating a dedicated non‑admin Foundry user with Edit permission if using
it.
What changed
docs/foundry-auto-deploy.mddescribing the OpenAPI -> Foundry functions import path and linking from existing Foundry docs.README.md./.github/workflows/publish-foundry.ymlto optionally mint a short-lived OAuth2 token (client credentials) for registry login, with a fallback toFOUNDRY_TOKEN.Why
Make the Foundry deployment story easier to understand and easier to automate: the OpenAPI contract becomes the single source of truth for function registration, and auth options are clearer for CI.
Notes
FOUNDRY_TOKENflow continues to work unchanged.Summary by CodeRabbit
New Features
Documentation