Skip to content

Commit 44c34a3

Browse files
committed
first commit
1 parent d1267ec commit 44c34a3

File tree

4 files changed

+118
-1
lines changed

4 files changed

+118
-1
lines changed

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Python
2+
**/__pycache__/
3+
**server.egg-info/
4+
**build/
5+
6+
.idea/*
7+
8+
# Python notebook checkpoints
9+
**/.ipynb_checkpoints/
10+
11+
commons.iml

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
# generate-docs
1+
# generate-docs
2+
TODO

action.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Generate Auto Documentation
2+
description: "Updates an OpenAPI spec file based on changes to a single API file."
3+
inputs:
4+
runllm_server_address:
5+
description: "The full host:port address to the RunLLM instance to use."
6+
required: false
7+
default: "api.runllm.com"
8+
runllm_api_key:
9+
description: "The API key to use for the RunLLM instance."
10+
required: true
11+
github_token:
12+
description: "The GitHub token to use for the GitHub repository."
13+
required: true
14+
input_api_file:
15+
description: "The file path for the input API file. It is expected to be a Python file."
16+
required: true
17+
output_spec_file:
18+
description: "The file path for the output OpenAPI spec file. It is expected to be a YML file."
19+
required: true
20+
base_branch:
21+
description: 'The base branch for the pull request'
22+
required: true
23+
default: 'main'
24+
25+
runs:
26+
using: "composite"
27+
steps:
28+
# TODO: add the checkout action here before publishing.
29+
30+
# TODO: remove
31+
# - name: Install tree
32+
# run: sudo apt-get install tree
33+
# shell: bash
34+
# - name: Print directory tree up to depth 4
35+
# run: tree -a -L 4
36+
# shell: bash
37+
38+
- name: Fetch main branch
39+
run: git fetch origin main:main
40+
shell: bash
41+
42+
- name: Compute diff against main
43+
run: git diff ${{ inputs.base_branch }}...HEAD > diff.txt
44+
shell: bash
45+
46+
# TODO: use a script instead of a bash command.
47+
# - name: Check that the input_api_file was involved in the diff
48+
# run: |
49+
# if ! grep -q ${{ inputs.input_api_file }} diff.txt; then
50+
# echo "Error: The input API file was not involved in the diff. Exiting."
51+
# exit 1
52+
# fi
53+
# shell: bash
54+
55+
- uses: actions/setup-python@v2
56+
with:
57+
python-version: '3.10'
58+
59+
- name: Install dependencies
60+
run: pip install -r requirements.txt
61+
shell: bash
62+
63+
- name: Set GH Action URL
64+
run: echo "GH_ACTION_URL=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> $GITHUB_ENV
65+
shell: bash
66+
67+
- name: Update OpenAPI Spec
68+
env:
69+
GITHUB_REPO_NAME: ${{ github.repository}}
70+
run: |
71+
python .github/scripts/generate_docs.py \
72+
--server-address ${{ inputs.runllm_server_address }} \
73+
--api-key ${{ inputs.runllm_api_key }} \
74+
--input-api-file ${{ inputs.input_api_file }} \
75+
--output-openapi-file ${{ inputs.output_spec_file }} \
76+
--mode openapi \
77+
--diffs diff.txt \
78+
shell: bash
79+
80+
- id: get-pr-body
81+
run: |
82+
body=$(cat pr-body.txt)
83+
body="${body//'%'/'%25'}"
84+
body="${body//$'\n'/'%0A'}"
85+
body="${body//$'\r'/'%0D'}"
86+
echo "pr_body=${body}" >> $GITHUB_OUTPUT
87+
shell: bash
88+
89+
- name: Remove temporary files
90+
run: rm -rf diff.txt pr-body.txt
91+
shell: bash
92+
93+
- name: Create Pull Request
94+
uses: peter-evans/create-pull-request@v3
95+
with:
96+
token: ${{ inputs.github_token }}
97+
commit-message: Update documentation
98+
title: "Update OpenAPI Spec"
99+
branch: autogenerated-docs-${{ github.run_id }}
100+
body: ${{ steps.get-pr-body.outputs.pr_body }}
101+
base: ${{ inputs.base_branch }}
102+
103+
# TODO: finish the autodoc workflow

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
requests==2.31.0
2+
pydantic==1.10.9

0 commit comments

Comments
 (0)