feat: WIP Deploy the on-going OpenAPI work #23
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build, test and deploy OpenAPI collection | |
on: | |
push: | |
branches: | |
- open-api-deploy | |
pull_request: | |
jobs: | |
build: | |
name: Build documentation | |
runs-on: ubuntu-18.04 | |
steps: | |
- name: Set deploy env | |
run: | | |
echo "off_env=${{ github.ref == 'refs/heads/develop' && 'off-org' || 'off-net'}}" >> $GITHUB_ENV | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Generate Swagger UI | |
uses: Legion2/swagger-ui-action@v1 | |
with: | |
output: docs/output/api/html/ | |
spec-file: docs/reference/api.yml | |
- name: Cat Swagger | |
run: cat docs/output/api/html/index.html | |
- name: Commit generated documentation to current branch | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
repository: . | |
commit_message: Commit docgen-generated docs | |
commit_options: '--no-verify --signoff' | |
- name: Deploy HTML docs to Github Pages [STAGING] | |
uses: JamesIves/[email protected] | |
if: ${{ startsWith(github.ref, 'refs/pull') }} | |
with: | |
token: ${{ secrets.CROSS_REPO_TOKEN }} | |
branch: gh-pages # <- Branch on which commit will be made | |
repository-name: openfoodfacts/openfoodfacts-server | |
folder: docs/output/api/html/ # <- Folder containing our generated HTML docs | |
- name: Deploy HTML docs to Github Pages [PROD] | |
uses: JamesIves/[email protected] | |
if: ${{ github.ref == 'refs/heads/master' }} | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
branch: gh-pages # <- Branch on which commit will be made | |
folder: swagger-ui # <- Folder containing our generated HTML docs |