Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- run: cp wrangler.toml.example wrangler.toml
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
- run: npm ci
- run: npm test

Expand All @@ -27,6 +27,7 @@ jobs:
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
preCommands: |
cp wrangler.toml.example wrangler.toml
envsubst < wrangler.toml.example > wrangler.toml
Expand All @@ -36,7 +37,7 @@ jobs:
secrets: |
INFLUX_TOKEN
env:
INFLUX_METRIC_NAME: ${{ env.INFLUX_METRIC }}
INFLUX_URL: ${{ env.INFLUX_URL }}
INFLUX_METRIC_NAME: ${{ vars.INFLUX_METRIC_NAME }}
INFLUX_URL: ${{ vars.INFLUX_URL }}
INFLUX_TOKEN: ${{ secrets.INFLUX_TOKEN }}
INFLUX_DATABASE: ${{ env.INFLUX_DATABASE }}
INFLUX_DATABASE: ${{ vars.INFLUX_DATABASE }}
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ cp wrangler.toml.example wrangler.toml
npm run dev
```

## Deployment to production
## Deployment (Github Actions)

In order to deploy your worker via Github Actions, you need to have a [Cloudflare API token](https://developers.cloudflare.com/fundamentals/api/get-started/create-token/) and running instance of InfluxDB.

Expand All @@ -34,4 +34,6 @@ Add generated API token to Github secrets as `CLOUDFLARE_API_TOKEN` and authenti
Other required environment variables include the following:
- `INFLUX_URL` - InfluxDB URL
- `INFLUX_DATABASE` - InfluxDB database (bucket) name
- `INFLUX_METRIC_NAME` - InfluxDB metric name
- `INFLUX_METRIC_NAME` - InfluxDB metric name

After setting up secrets, you can push your code to Github and worker will be deployed to production environment automatically.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"description": "A template for kick starting a Cloudflare Workers project",
"main": "index.js",
"scripts": {
"deploy": "wrangler deploy",
"deploy:prod": "wrangler deploy --env production",
"deploy": "wrangler deploy --env production",
"deploy:dev": "wrangler deploy --env dev",
"dev": "wrangler dev --env dev",
"start": "wrangler dev",
"test": "vitest run",
Expand Down
Loading