forked from janlay/openai-cloudflare
-
Notifications
You must be signed in to change notification settings - Fork 3
102 lines (91 loc) · 3.3 KB
/
deploy-proxy.yaml
File metadata and controls
102 lines (91 loc) · 3.3 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# Copyright (c) 2024-2026 Ronan LE MEILLAT
# License: AGPL-3.0-or-later
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
name: Deploy Cloudflare Worker
on:
push:
branches:
- master
paths:
- src/**
- package-lock.json
- .github/workflows/deploy-proxy.yaml
- .github/workflows/create-env-artifact.yaml
- scripts/generate-wrangler-jsonc.py
- wrangler.jsonc
# schedule:
# # 1st and 15th of each month at midnight UTC
# - cron: "0 0 1,15 * *"
workflow_dispatch:
permissions:
contents: read
id-token: write # Required for OIDC
jobs:
create-env:
uses: ./.github/workflows/create-env-artifact.yaml
secrets: inherit
deploy:
needs: create-env
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
submodules: "recursive"
fetch-depth: 1
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: "24"
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm install
- name: Download shared .env artifact
uses: actions/download-artifact@v5
with:
name: shared-env
path: .
# .env.enc was encrypted with openssl enc -aes-256-cbc -salt -in env_and_wrangler.tar.gz -out .env.enc -iter 10000 -pass pass:"${{ secrets.CRYPTOKEN }}"
- name: Decrypt .env + wrangler.jsonc artifact
run: |
openssl enc -aes-256-cbc -d -salt -in .env.enc -out env_and_wrangler.tar.gz -iter 10000 -pass pass:"${{ secrets.CRYPTOKEN }}"
tar -xzvf env_and_wrangler.tar.gz
rm env_and_wrangler.tar.gz .env.enc
if [ ! -f wrangler.jsonc ]; then
echo "Decrypted artifact does not contain wrangler.jsonc"
exit 1
fi
if [ ! -f secrets.json ]; then
echo "Decrypted artifact does not contain secrets.json"
exit 1
fi
- name: Set Wrangler secrets in bulk from secrets.json
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CRYPTOKEN: ${{ secrets.CRYPTOKEN }}
run:
npx wrangler secret bulk < secrets.json
- name: Deploy Proxy Worker
uses: cloudflare/wrangler-action@v3
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CRYPTOKEN: ${{ secrets.CRYPTOKEN }}
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
workingDirectory: .