forked from pyropy/cf-metrics
-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (44 loc) · 1.38 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: cp wrangler.toml.example wrangler.toml
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm test
deploy:
if: github.ref == 'refs/heads/main'
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Deploy
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
preCommands: |
cp wranger.toml.example wrangler.toml
echo "[env.production.vars]" >> wrangler.toml
echo "ENVIRONMENT = 'production'" >> wrangler.toml"
echo "INFLUX_URL = '${{ env.INFLUX_URL }}'" >> wrangler.toml
echo "INFLUX_METRIC_NAME = '${{ env.INFLUX_METRIC_NAME }}'" >> wrangler.toml
echo "INFLUX_DATABASE = '${{ env.INFLUX_DATABASE }}'" >> wrangler.toml
postCommands: |
rm -f wrangler.toml
environment: production
secrets: |
INFLUX_TOKEN
env:
INFLUX_METRIC_NAME: ${{ env.INFLUX_METRIC }}
INFLUX_URL: ${{ env.INFLUX_URL }}
INFLUX_TOKEN: ${{ secrets.INFLUX_TOKEN }}
INFLUX_DATABASE: ${{ env.INFLUX_DATABASE }}