forked from simonw/tools
-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (73 loc) · 2.46 KB
/
deploy-cloudflare-workers.yml
File metadata and controls
83 lines (73 loc) · 2.46 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: Deploy Cloudflare Workers
on:
push:
branches:
- main
paths:
- 'cloudflare-workers/**'
workflow_dispatch: # Allow manual triggering
jobs:
changes: # Use https://github.com/dorny/paths-filter to check what workers were changed
name: Detect Cloudflare worker changes
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
social_link_preview: ${{ steps.filter.outputs.social-link-preview }}
workouts: ${{ steps.filter.outputs.workouts }}
# If I add more filters below, I need to “export them” here.
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
social-link-preview:
- 'cloudflare-workers/social-link-preview/**'
workouts:
- 'cloudflare-workers/workouts/**'
# I can add more filters here and access them separately.
deploy-social-link-preview:
name: Deploy Social Link Preview Worker
runs-on: ubuntu-latest
needs: changes
if: ${{ github.event_name == 'workflow_dispatch' || needs.changes.outputs.social_link_preview == 'true' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Wrangler
run: npm install -g wrangler
- name: Deploy to Cloudflare Workers
working-directory: cloudflare-workers/social-link-preview
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: |
wrangler deploy --env production
deploy-workouts:
name: Deploy Workouts Worker
runs-on: ubuntu-latest
needs: changes
if: ${{ github.event_name == 'workflow_dispatch' || needs.changes.outputs.workouts == 'true' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Wrangler
run: npm install -g wrangler
- name: Deploy to Cloudflare Workers
working-directory: cloudflare-workers/workouts
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: |
wrangler deploy --env production