Repository navigation
feat: new docs #1
Workflow file for this run
This file contains hidden or 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: API Docs | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - "docs/api/swagger.yaml" | |
| pull_request: | |
| paths: | |
| - "api/**/*" | |
| - "scripts/generate-swagger.sh" | |
| - "scripts/generate-swagger-ui.sh" | |
| jobs: | |
| api-swagger: | |
| name: Generate swagger.yaml | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: actions/setup-go@v7 | |
| with: | |
| go-version-file: "go.mod" | |
| cache: false | |
| - name: Make swagger.yaml | |
| run: ./scripts/generate-swagger.sh | |
| - name: Publish Artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: swagger.yaml | |
| path: docs/api/swagger.yaml | |
| - name: Check if there is a difference | |
| uses: mathiasvr/command-output@v2.0.0 | |
| id: diff | |
| with: | |
| run: git diff --no-color docs/api/swagger.yaml | |
| - name: Mark previous comment as outdated if no diff | |
| if: ${{ github.event_name == 'pull_request' && steps.diff.outputs.stdout == '' }} | |
| uses: marocchino/sticky-pull-request-comment@v3 | |
| with: | |
| header: diff | |
| hide: true | |
| hide_classify: "OUTDATED" | |
| - name: Post comment with diff in original PR | |
| if: ${{ github.event_name == 'pull_request' && steps.diff.outputs.stdout }} | |
| uses: marocchino/sticky-pull-request-comment@v3 | |
| with: | |
| header: diff | |
| message: | | |
| This PR introduces the following changes in the API documentation: | |
| ```diff | |
| ${{ steps.diff.outputs.stdout }} | |
| ``` | |
| - name: Commit and push if stage is outdated | |
| if: ${{ github.event_name == 'push' && steps.diff.outputs.stdout }} | |
| run: | | |
| git config user.name "github-actions" | |
| git config user.email "github-actions@users.noreply.github.com" | |
| git add docs/api/swagger.yaml | |
| git commit -m "ci: regenerate swagger.yaml after merge" | |
| git push | |
| deploy-pages: | |
| name: Deploy docs site and Swagger UI to GitHub Pages | |
| needs: api-swagger | |
| if: github.event_name == 'push' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| actions: read | |
| contents: read | |
| pages: write | |
| id-token: write | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: false | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Overwrite docs/api/swagger.yaml with the freshly generated spec | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: swagger.yaml | |
| path: docs/api | |
| - name: Generate Swagger UI assets | |
| run: ./scripts/generate-swagger-ui.sh | |
| - name: Setup Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| bundler-cache: true | |
| - name: Build docs site with Jekyll | |
| run: bundle exec jekyll build --source docs --destination _site | |
| - uses: actions/configure-pages@v6 | |
| - name: Upload built site | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: _site | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v5 |