https://github.com/nusmodifications/deploy-preview-bot
https://github.com/nusmodifications/deploy-preview-bot
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/nusmodifications/deploy-preview-bot
- Owner: nusmodifications
- License: isc
- Created: 2019-11-02T22:45:49.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-03T08:04:53.000Z (over 6 years ago)
- Last Synced: 2024-04-14T05:15:18.286Z (about 2 years ago)
- Language: TypeScript
- Homepage: https://deploy-preview-bot-pale-tin.now.sh
- Size: 132 KB
- Stars: 0
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# NUSMods Deploy Previw Bot
Automatically deploys built artifacts from successful CircleCI deploys to Netlify using a GitHub webhook, then link the deploy to the pull request on GitHub. Currently deployed as a serverless function on now.sh - https://circleci.com/docs/api/#recent-builds-for-a-single-project
Built with ProBot: https://probot.github.io/docs/development/
API documentations
- Netlify: https://docs.netlify.com/api/get-started/#zip-file-method
- OctoKit: https://octokit.github.io/rest.js/#octokit-routes-issues
- CircleCI: https://circleci.com/docs/api/#recent-builds-for-a-single-project
## Development and Testing
To test the function locally, use the following commands
```sh
# Compile TypeScript
yarn watch
# Lint code
yarn lint
# Run Probot locally using the given fixture as the webhook event
yarn probot receive -e check_suite.completed -p ./fixture/check_suite.completed.json ./lib/src/webhook.js
```
## Deployment
Deploy using the `now` command
```sh
# Install now CLI
yarn global add now
# Deploy to personal now.sh instance
now
```
This deploys the `/api` folder as a serverless function. Since now.sh supports TypeScript natively, we don't need a build script. The webhook will be accessible at `/api`.
## Secrets
To add a sensitive env variable, use `now secret` to add the secret to now.sh, then map the variable to an env variable in Node in the `now.json` config file. You also need to add the same env variable to `.env` and `.env.example` since we do not load secrets from now.sh in development.