diff --git a/.github/workflows/openapi2_golang_build.yaml b/.github/workflows/openapi2_golang_build.yaml new file mode 100644 index 0000000..ca8adf2 --- /dev/null +++ b/.github/workflows/openapi2_golang_build.yaml @@ -0,0 +1,39 @@ +on: + workflow_call: + inputs: + entrypoint: + required: false + type: string + default: "main.go" + workdir: + required: false + type: string + default: "./" + +jobs: + build_with_swagger: + runs-on: ubuntu-latest + if: "!startsWith(github.ref, 'refs/tags/')" + container: + image: cubicrootxyz/golang-ci:v1.23.0 + options: --user root + steps: + - name: Checkout the repository + uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + - uses: actions/setup-node@v3 + with: + node-version: "14" + - name: Get dependencies + run: (cd ${{ inputs.workdir }} && go get ./...) + - name: Make docs folder + run: mkdir -p docs + - name: Build the api documentation + run: swag init --parseDependency=true -d . -g ${{ inputs.entrypoint }} + - name: Archive OpenAPI spec + uses: actions/upload-artifact@v4 + with: + name: openapi-spec + path: | + docs/ \ No newline at end of file diff --git a/.github/workflows/openapi2_golang_build_test.yaml b/.github/workflows/openapi2_golang_build_test.yaml new file mode 100644 index 0000000..d8874cb --- /dev/null +++ b/.github/workflows/openapi2_golang_build_test.yaml @@ -0,0 +1,8 @@ +on: push + +jobs: + openapi2_golang_build_test: + uses: ./.github/workflows/openapi2_golang_build.yaml + with: + entrypoint: tests/openapi2/main.go + workdir: tests/openapi2/ \ No newline at end of file diff --git a/tests/openapi2/go.mod b/tests/openapi2/go.mod new file mode 100644 index 0000000..7460429 --- /dev/null +++ b/tests/openapi2/go.mod @@ -0,0 +1,3 @@ +module openapi2 + +go 1.23.0 diff --git a/tests/openapi2/main.go b/tests/openapi2/main.go new file mode 100644 index 0000000..320a5cd --- /dev/null +++ b/tests/openapi2/main.go @@ -0,0 +1,22 @@ +package main + +import ( + "os" +) + +// @title Matrix Reminder and Calendar Bot (RemindMe) +// @version 2.0.0 +// @description API documentation for the matrix reminder and calendar bot. + +// @contact.name Support + +// @host your-bot-domain.tld +// @BasePath / +// @query.collection.format multi + +// @securityDefinitions.apikey APIKeyAuthentication +// @in header +// @name Authorization +func main() { + os.Exit(0) +}