Skip to content

Commit

Permalink
redocでAPI doc を作成した (#88)
Browse files Browse the repository at this point in the history
* Create static.yml

* static.yml完成

* README更新

* workflow_dispatchに変更
  • Loading branch information
shun-harutaro committed Sep 23, 2024
1 parent 178edd2 commit db7b7d1
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 2 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Deploy API doc to Pages

on:
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create .env file
run: |
touch .env
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> .env
echo "VOICEVOX_API_KEY=${{ secrets.VOICEVOX_API_KEY }}" >> .env
- name: Run docker-compose Build
run: |
docker compose -f docker-compose.yml -f docker-compose.dev.yml up --build -d
sleep 5
curl http://localhost
- name: Wait for the API to be ready
run: |
for i in {1..60}; do
curl -s http://localhost/openapi.json && break
echo "Waiting for API to be ready..."
sleep 2
done
- name: Download OpenAPI Specification
run: |
curl -o openapi.json http://localhost/openapi.json
- name: Generate Redoc HTML
run: |
mkdir -p docs
cp openapi.json docs/
echo '<!DOCTYPE html>
<html>
<head>
<title>API Documentation</title>
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"></script>
<style>
body { margin: 0; }
#redoc-container { padding: 20px; }
</style>
</head>
<body>
<div id="redoc-container"></div>
<script>
Redoc.init("openapi.json", {}, document.getElementById("redoc-container"));
</script>
</body>
</html>' > docs/index.html
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'docs/'
retention-days: 7

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ touch .env
echo "VOICEVOX_API_KEY=[voicevox api key]" >> .env
echo "OPENAI_API_KEY=[openAI api key]" >> .env
```
`VOICEVOX_API_KEY`https://su-shiki.com/api/ から、
`VOICEVOX_API_KEY`https://su-shiki.com/api/ から、
`OPENAI_API_KEY`https://platform.openai.com/docs/overview から取得します

3. Dockerイメージのビルド
Expand All @@ -57,7 +57,7 @@ sudo make stop
```

## APIエンドポイント(v1)
詳しくは http://localhost/docs を参照してください。
詳しくは https://futaringoto.github.io/futarin-api/ を参照してください。
| メソッド | パス | 概要 |
| :----- | :-- | :-- |
| POST | `/v1/raspi` | 一連の処理全て |
Expand Down

0 comments on commit db7b7d1

Please sign in to comment.