0

I am generating an HTML file from a .yaml file using AsyncAPI for documentation within my project - I want to host this documentation on Vercel, but only that file within my project using a GitHub action so that every time a change is pushed or a PR is merged it redeploys in Vercel. What is the best way to go about this?

sbuck89
  • 123
  • 3
  • 6

1 Answers1

1

The easiest way to do this is a simple script that would be fired from Vercel context. When a new commit is committed, Vercel runs the given script to generate documentation and deploys the output of this generation.

So I would create a simple, private NodeJS package with the @asyncapi/generator and @asyncapi/html-template dependencies and then configure Vercel either through the UI on admin site or through the vercel.js file:

  • package.json:

    {
      "devDependencies": {
        "@asyncapi/generator": "^1.9.11",
        "@asyncapi/html-template": "^0.25.2"
      },
      "scripts": {
        "build": "./node_modules/.bin/asyncapi-generator {PATH_TO_SPEC} @asyncapi/html-template -o {OUTPUT_FOLDER} --force-write ...{OTHER_PARAMS}"
      }
    }
    
  • vercel.json:

    {
       "buildCommand": "npm run build",
       "outputDirectory": "{OUTPUT_FOLDER}"
    }
    

I haven't tested it, but I would go in that direction :) Of course the generated html file should be index.html.

matatjahu
  • 116
  • 1