diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1896f91e..496b2def3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,43 +29,6 @@ jobs: - name: Check Vulnerabilities run: mage -v vuln - generate-spec: - runs-on: ubuntu-latest - steps: - - name: fetch history - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: 1.19.4 - cache: true - - - name: Install Mage - run: go install github.com/magefile/mage - - - name: Update to latest spec - shell: bash - run: | - export PATH=$PATH:$(go env GOPATH)/bin - go install github.com/swaggo/swag/cmd/swag@v1.8.7 - mage spec - - - name: Push generated spec file - uses: actions/checkout@v3 - - run: | - git config --global user.name "${GITHUB_ACTOR}" - git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" - if (git diff --shortstat | grep '[0-9]'); then \ - git add .; \ - git commit -m "gen OpenAPI Spec by github-actions"; \ - git push - fi - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - build: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/swagger-doc.yml b/.github/workflows/swagger-doc.yml new file mode 100644 index 000000000..2c1bba362 --- /dev/null +++ b/.github/workflows/swagger-doc.yml @@ -0,0 +1,42 @@ +name: swagger-doc + +on: + push: + branches: + - main + +jobs: + + generate-swagger: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.19.4 + cache: true + + - name: Install Mage + run: go install github.com/magefile/mage + + - name: Update spec and push generated spec file + uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - run: | + export PATH=$PATH:$(go env GOPATH)/bin + mage spec + git config user.name github-actions + git config user.email github-actions@github.com + if (git diff --shortstat | grep '[0-9]'); then \ + git checkout -B main_swagger + git add .; \ + git commit -m "gen OpenAPI Spec by github-actions"; \ + git push + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/magefile.go b/magefile.go index d65c4fd55..f076ccdde 100644 --- a/magefile.go +++ b/magefile.go @@ -108,7 +108,11 @@ func Integration() error { // Spec generates an OpenAPI spec yaml based on code annotations. func Spec() error { swagCommand := "swag" - if err := installIfNotPresent(swagCommand, "github.com/swaggo/swag/cmd/swag@latest"); err != nil { + if err := installIfNotPresent(swagCommand, "github.com/swaggo/swag/cmd/swag@v1.8.7"); err != nil { + logrus.Fatal(err) + return err + } + if err := sh.Run(swagCommand, "fmt", "-d", "pkg/server/router"); err != nil { logrus.Fatal(err) return err } diff --git a/pkg/server/router/presentation.go b/pkg/server/router/presentation.go index 0e5097bc5..3dc6b2a01 100644 --- a/pkg/server/router/presentation.go +++ b/pkg/server/router/presentation.go @@ -374,7 +374,7 @@ type ReviewSubmissionResponse struct { } // ReviewSubmission godoc -// @Summary Review a pending submissions +// @Summary Review a pending submission // @Description Reviews a pending submission. After this method is called, the operation with `id==presentations/submissions/{submission_id}` will be updated with the result of this invocation. // @Tags SubmissionAPI // @Accept json