https://github.com/featurevisor/featurevisor-example-cloudflare
Featurevisor CI/CD example with GitHub Actions & Cloudflare Pages
https://github.com/featurevisor/featurevisor-example-cloudflare
Last synced: about 1 year ago
JSON representation
Featurevisor CI/CD example with GitHub Actions & Cloudflare Pages
- Host: GitHub
- URL: https://github.com/featurevisor/featurevisor-example-cloudflare
- Owner: featurevisor
- License: mit
- Created: 2023-05-29T14:06:43.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-12-21T19:32:50.000Z (over 1 year ago)
- Last Synced: 2024-12-21T20:24:52.870Z (over 1 year ago)
- Language: JavaScript
- Homepage: https://featurevisor.com/docs/integrations/cloudflare-pages/
- Size: 196 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# featurevisor-example-cloudflare
Example Featurevisor project utilizing [Cloudflare Pages](https://developers.cloudflare.com/pages).
For more documentation, visit https://featurevisor.com.
## Accessing datafiles
The generated datafiles from this repository is accessible via these URLs:
- `production`: https://featurevisor-example-cloudflare.pages.dev/production/datafile-tag-all.json
- `staging`: https://featurevisor-example-cloudflare.pages.dev/staging/datafile-tag-all.json
### Usage with Featurevisor SDK
Install the SDK in your application:
```
$ npm install --save @featurevisor/sdk
```
Then use it in your application:
```js
import { createInstance } from '@featurevisor/sdk';
const sdk = createInstance({
datafileUrl: 'https://featurevisor-example-cloudflare.pages.dev/production/datafile-tag-all.json',
});
```
## Installation
Since this example app lives outside of the Featurevisor [monorepo](https://github.com/fahad19/featurevisor), you are recommended to make sure [`package.json`](./package.json) has the latest version of [`@featurevisor/cli`](https://www.npmjs.com/package/@featurevisor/cli) package.
```
$ npm ci
```
## Usage
### Lint YAMLs
```
$ npm run lint
```
### Build datafiles
```
$ npm run build
```
### Test features
```
$ npm test
```
## Cloudflare
For this example, we are going to be uploading to and serving our datafiles from [Cloudflare Pages](https://pages.cloudflare.com/).
Make sure you already have a Cloudflare Pages project set up, and then use it in the [`publish`](./.github/workflows/publish.yml) workflow.
## GitHub Actions
This example project is configured to run its CI/CD pipeline with [GitHub Actions](https://github.com/features/actions).
You are free to choose any other CI/CD provider of your choice.
### Settings
Make sure you have `Read and write permissions` enabled in your GitHub repository's `Settings > Actions > General > Workflow permissions` section.
### Workflows
You can find the GHA workflow files in [`.github/workflows`](./.github/workflows) directory.
- `checks` workflow: runs against non-`master` (non-`main`) branches
- `publish` workflow: runs against `master` (`main`) branch
### Secrets
Follow the guide [here](https://developers.cloudflare.com/pages/how-to/use-direct-upload-with-continuous-integration/), and set up these two secrets in your GitHub repository's `Settings > Secrects and variables > Actions` section:
- `CLOUDFLARE_ACCOUNT_ID`
- `CLOUDFLARE_API_TOKEN`
## License
MIT © [Fahad Heylaal](https://fahad19.com)