Skip to content

feat: self-contained tokens #14

feat: self-contained tokens

feat: self-contained tokens #14

Workflow file for this run

name: API Swagger Docs
on:
push:
branches:
- main
paths-ignore:
- "docs/swagger.yaml"
pull_request:
paths:
- "api/**/*"
- "scripts/generate-swagger.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/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/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/swagger.yaml
git commit -m "ci: regenerate swagger.yaml after merge"
git push
deploy-pages:
name: Deploy 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/swagger.yaml with the freshly generated spec
uses: actions/download-artifact@v4
with:
name: swagger.yaml
path: docs
- uses: actions/configure-pages@v6
- name: Upload docs/ (Swagger UI + spec)
uses: actions/upload-pages-artifact@v3
with:
path: docs
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5