Advertisement
dvjsharma

Untitled

Feb 7th, 2024
813
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.59 KB | None | 0 0
  1. name: Swagger API Updated
  2.  
  3. on:
  4.   pull_request:
  5.     branches: [ "main" ]
  6.   workflow_dispatch:
  7. jobs:
  8.   doc-diff:
  9.     runs-on: ubuntu-latest
  10.     steps:
  11.     - uses: actions/checkout@v3
  12.  
  13.     - name: Set up Go
  14.       uses: actions/setup-go@v4
  15.       with:
  16.         go-version: '1.20'
  17.         check-latest: true
  18.         cache: true
  19.  
  20.     - name: Install swag
  21.       run: |
  22.        go install github.com/swaggo/swag/cmd/swag@latest
  23.  
  24.     - name: Build Swagger documents
  25.       run: |
  26.        swag init --generalInfo api.go --dir ./pkg/api,./pkg/auth,./pkg/db,./pkg/models,./pkg/utils --output ./swag/docs
  27.  
  28.     - name: Check doc diff
  29.       run: |
  30.        diff swag/docs/docs.go cmd/laas/docs/docs.go > swagger-diff.txt
  31.         # Check if file swagger-diff.txt is empty
  32.         if [ -s swagger-diff.txt ]
  33.         then
  34.           # If file is not empty, echo a message and exit 1
  35.           echo "Swagger docs are not up to date. Please run 'swag init' and commit the changes."
  36.           exit 1
  37.         fi
  38.  
  39.   doc-fmt:
  40.     runs-on: ubuntu-latest
  41.     steps:
  42.       - uses: actions/checkout@v3
  43.  
  44.       - name: Set up Go
  45.         uses: actions/setup-go@v4
  46.         with:
  47.           go-version: '1.20'
  48.           check-latest: true
  49.           cache: true
  50.  
  51.       - name: Install swag
  52.         run: |
  53.          go install github.com/swaggo/swag/cmd/swag@latest
  54.  
  55.       - name: Format Swagger documents
  56.         run: |
  57.          swag fmt --generalInfo ./pkg/api/api.go --dir ./pkg/api,./pkg/auth,./pkg/db,./pkg/models,./pkg/utils
  58.  
  59.       - name: Check file diff
  60.         run: |
  61.          git diff --exit-code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement