Example how to build an API serverless function and deploy it to Zeit Now using Semaphore.
-
Fork this repository and use it to create a project.
-
Go to your Now dashboard, and add a token. You should see a slightly hidden field in the middle of the page that says "Create a new token by entering its name..." I'd recommend calling it something obvious like
zeit-now-semaphoreci-yourproject
. -
Take the token, and create an Secret and add an Environment Variable in your project's configuration in SemaphoreCI. This sample repo calls the Secret
now
and Environment VariableZEIT_TOKEN
, so I'd suggest doing the same - if you change it, be aware that you'll need to change references to this token name in the sample files.
The CI pipeline will look like this:
The example pipeline contains 3 blocks:
- Install dependencies
- installs and caches all npm dependencies
- Run tests
- Runs Tests using Jest framework (https://jestjs.io/)
- Deploy
- Deploys the server using Zeist Now (https://zeit.co/now)
$ npm install
$ npm install -g now
$ npm start
$ npm test
$ npm install -g now
$ now login
$ now deploy
Copyright (c) 2019 Rendered Text
Distributed under the MIT License. See the file LICENSE.md.