# Deployment

_This guide explains how the Homepage is deployed._

## Services

* Local
* Github
* Cloudflare

## Runtime secrets

`make deploy` reads selected server-only values from local `.env` and syncs them to the Cloudflare Worker before pushing the deployment package. For annotations, edit `N8N_ANNOTATIONS_WEBHOOK_URL` only in `.env`; deployment uploads that value as the Worker secret of the same name.

For production cohort personalization, set `POSTHOG_PROJECT_ID_PROD` and `POSTHOG_COHORTS_TOKEN_PROD` in `.env`. The project ID is added to the deployed Worker's `[vars]`; the dedicated API token is synced as a server-only Worker secret. Give that token `person:read` and `cohort:read` scope. Keep the browser SDK token (`POSTHOG_PROJECT_TOKEN_PROD`) separate; it is not an API token and cannot be used for cohort lookup. Local development uses `POSTHOG_PROJECT_ID_DEV` and `POSTHOG_COHORTS_TOKEN_DEV`.

## Quick

```bash [v] Terminal: All
cd ~/Development/Artificial-Colleagues/Homepage-Builder/work
make commit m="<Message>"
make deploy
```

Individual lines:

```bash [<] Terminal: Go to directory
cd ~/Development/Artificial-Colleagues/Homepage-Builder/work
```

```bash [<] Terminal: Commit current changes
make commit m="<Message>"
```

```bash [<] Terminal: Push and deploy
make deploy
```

## Considerate

1. Go to the `work` directory of the Assistant:

```bash [<] Terminal
cd ~/Development/Artificial-Colleagues/Homepage-Builder/work
```

2. Test the Homepage locally first:

```bash [<] Terminal
make dev
```

3. Then commit all changes to Github:

```bash
make commit m="<Message>"
```

4. Finally deploy to Cloudflare:

```bash
make deploy
```

5. Check the results:
  * Github
    * [Repository](https://github.com/sefzig/Homepage)
  * Cloudflare
    * [Deployment history](https://dash.cloudflare.com/4f722dd39a6e92cf0e0196bd1f2832e4/workers/services/view/homepage/production/deployments)
    * [Observability Logs](https://dash.cloudflare.com/4f722dd39a6e92cf0e0196bd1f2832e4/workers/services/view/homepage/production/observability/events?filterCombination=%22and%22&calculations=%5B%7B%22operator%22%3A%22count%22%7D%5D&orderBy=%7B%22value%22%3A%22count%22%2C%22limit%22%3A10%2C%22order%22%3A%22desc%22%7D&timeframe=1h&conditions=%7B%7D&conditionCombination=%22and%22&alertTiming=%7B%22interval%22%3A300%2C%22window%22%3A900%2C%22timeBeforeFiring%22%3A600%2C%22timeBeforeResolved%22%3A600%7D)
