-
Notifications
You must be signed in to change notification settings - Fork 0
chore: Add job to generate api docs #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| name: api-doc | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - 'gen-v*' | ||
| - 'base-v*' | ||
| - 'core-v*' | ||
| workflow_dispatch: ~ | ||
|
|
||
| jobs: | ||
| doc: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
|
|
||
| steps: | ||
| - name: Generate GitHub App token | ||
| id: app-token | ||
| uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 | ||
| with: | ||
| client-id: ${{ secrets.SAP_AI_SDK_BOT_CLIENT_ID }} | ||
| private-key: ${{ secrets.SAP_AI_SDK_BOT_PRIVATE_KEY }} | ||
| repositories: | | ||
| ai-sdk-python | ||
| ai-sdk | ||
| permission-contents: write | ||
| permission-pull-requests: write | ||
|
|
||
| - name: Setup | ||
| uses: SAP/ai-sdk-python/.github/actions/setup@main | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. q: Is it intended that we don't pin this branch to a SHA? |
||
| with: | ||
| token: ${{ steps.app-token.outputs.token }} | ||
| ref: ${{ github.ref }} | ||
| index-username: ${{ secrets.ARTIFACTORY_USERNAME }} | ||
| index-token: ${{ secrets.ARTIFACTORY_TOKEN }} | ||
|
|
||
| - name: Generate docs | ||
| run: uv run make docs | ||
|
|
||
| - name: Checkout sap/ai-sdk | ||
| uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 | ||
| with: | ||
| repository: SAP/ai-sdk | ||
| token: ${{ steps.app-token.outputs.token }} | ||
| path: ai-sdk | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| persist-credentials: false | ||
|
|
||
| - name: Configure git | ||
| env: | ||
| BOT_EMAIL: ${{ vars.SAP_AI_SDK_BOT_EMAIL }} | ||
| BOT_NAME: ${{ vars.SAP_AI_SDK_BOT_NAME }} | ||
| run: | | ||
| git -C ai-sdk config user.email "$BOT_EMAIL" | ||
| git -C ai-sdk config user.name "$BOT_NAME" | ||
|
|
||
| - name: Update api docs | ||
| id: update-docs | ||
| env: | ||
| TAG: ${{ github.ref_name }} | ||
| run: | | ||
| BRANCH="api-docs-python-$TAG-$(date +%Y%m%d)" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. q: I wanted to ask whether it could be a problem that we generate multiple api docs per day. Maybe, it makes sense to add a 5-6 char long salt at the end to randomize it? |
||
| echo "branch=$BRANCH" >> "$GITHUB_OUTPUT" | ||
| cd ai-sdk | ||
| git checkout -b "$BRANCH" | ||
| rm -rf static/api-python | ||
| cp -r ../api-docs/ static/api-python | ||
| git add static/api-python | ||
| if git diff --cached --quiet; then | ||
| echo "No documentation changes to commit" | ||
| echo "changed=false" >> "$GITHUB_OUTPUT" | ||
| else | ||
| git commit -m "chore: update Python API docs ($TAG)" | ||
| git push origin "$BRANCH" | ||
| echo "changed=true" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Create pull request | ||
| if: steps.update-docs.outputs.changed == 'true' | ||
| env: | ||
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | ||
| TAG: ${{ github.ref_name }} | ||
| TAG_URL: ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }} | ||
| BRANCH: ${{ steps.update-docs.outputs.branch }} | ||
| run: | | ||
| gh pr create \ | ||
| --repo SAP/ai-sdk \ | ||
| --base main \ | ||
| --head "$BRANCH" \ | ||
| --title "chore: update Python API docs ($TAG)" \ | ||
| --body "Automated update of Python API docs from [$TAG]($TAG_URL) in SAP/ai-sdk-python." | ||
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pp: I think we can stack #64 on top of this PR too, since it affects similar files.