Merge pull request #28 from code1mountain/docs

Add Swagger Docs on Github pages
This commit is contained in:
Andrea Cavalli 2021-01-05 20:52:49 +01:00 committed by GitHub
commit abcce9d33f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 12163 additions and 0 deletions

46
.github/workflows/docs-gh-pages.yml vendored Normal file
View File

@ -0,0 +1,46 @@
name: Generate and Deploy Swagger Docs on Github Pages
on:
push:
branches:
- master
paths:
- tdlight-api-openapi.yaml
jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get latest swagger version
id: swagger-ui
run: |
echo ::set-output name=release_tag::$(curl -sL https://api.github.com/repos/swagger-api/swagger-ui/releases/latest | jq -r ".tag_name")
- name: Generate Docs
env:
RELEASE_TAG: ${{ steps.swagger-ui.outputs.release_tag }}
SWAGGER_YAML: "tdlight-api-openapi.yaml"
TITLE: "tdlight Telegram bot API docs"
run: |
mkdir docs
cp -r icons/ docs/icons/
cp tdlight-api-openapi.yaml docs/tdlight-api-openapi.yaml
cd docs
# Download the release
curl -sL -o $RELEASE_TAG https://api.github.com/repos/swagger-api/swagger-ui/tarball/$RELEASE_TAG
# Extract the dist directory
tar -xzf $RELEASE_TAG --strip-components=1 $(tar -tzf $RELEASE_TAG | head -1 | cut -f1 -d"/")/dist
rm $RELEASE_TAG
# Move index.html
mv dist/index.html .
# Fix references in index.html
sed -i "s|https://petstore.swagger.io/v2/swagger.json|$SWAGGER_YAML|g" index.html
sed -i "s|href=\"./|href=\"dist/|g" index.html
sed -i "s|src=\"./|src=\"dist/|g" index.html
sed -i "s|dist/favicon|icons/favicon|g" index.html
sed -i "s|<title>.*</title>|<title>$TITLE</title>|g" index.html
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs

13
.github/workflows/validate-swagger.yml vendored Normal file
View File

@ -0,0 +1,13 @@
name: Documentation
on: [push, pull_request]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Validate openAPI
id: validate
uses: mbowman100/swagger-validator-action@2.0
with:
files: tdlight-api-openapi.yaml

BIN
icons/favicon-16x16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 657 B

BIN
icons/favicon-196x196.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
icons/favicon-32x32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

12104
tdlight-api-openapi.yaml Normal file

File diff suppressed because it is too large Load Diff