forked from codebam/cf-workers-telegram-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (52 loc) · 2.47 KB
/
publish.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
47
48
49
50
51
52
53
name: deploy to cloudflare workers
on:
push:
branches:
- master
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: github release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GH_TOKEN }}
publish:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- id: node-modules-cache
uses: actions/cache@v3
with:
path: |
node_modules
key: node-modules-${{ hashFiles('package-lock.json') }}
restore-keys: node-modules-
- name: cloudflare workers publish
uses: cloudflare/[email protected]
with:
accountId: ${{ secrets.CF_ACCOUNT_ID }}
apiToken: ${{ secrets.CF_API_TOKEN }}
preCommands: |
# wrangler kv:namespace create KV_GET_SET
# wrangler kv:namespace create KV_UID_DATA
# uncomment this for one build to enable KV
# echo 'import{stdin,stdout}from"process";(async()=>{let t="";for await(const i of stdin)t+=i;return t})().then((t=>{stdout.write(JSON.stringify(JSON.parse(t).filter((t=>t.title.includes("KV_GET_SET")))[0].id))}));' > get_kv_id.mjs
# echo 'import{stdin,stdout}from"process";(async()=>{let t="";for await(const i of stdin)t+=i;return t})().then((t=>{stdout.write(JSON.stringify(JSON.parse(t).filter((t=>t.title.includes("KV_UID_DATA")))[0].id))}));' > get_kv_id2.mjs
# export KV_NAMESPACE_ID=$(wrangler kv:namespace list | node get_kv_id.mjs)
# export KV_NAMESPACE_ID2=$(wrangler kv:namespace list | node get_kv_id2.mjs)
# echo "kv_namespaces = [{binding=\"KV_GET_SET\", id=${KV_NAMESPACE_ID}},{binding=\"KV_UID_DATA\", id=${KV_NAMESPACE_ID2}}]" >> wrangler.toml
[ -z "$SECRET_TELEGRAM_API_TOKEN" ] && echo "Secret SECRET_TELEGRAM_API_TOKEN not set, creating dummy one..." && SECRET_TELEGRAM_API_TOKEN="default-gh-action-secret" || true
secrets: |
SECRET_TELEGRAM_API_TOKEN
SECRET_TELEGRAM_API_TOKEN2
SECRET_TELEGRAM_API_TOKEN3
env:
SECRET_TELEGRAM_API_TOKEN: ${{ secrets.SECRET_TELEGRAM_API_TOKEN }}
SECRET_TELEGRAM_API_TOKEN2: ${{ secrets.SECRET_TELEGRAM_API_TOKEN2 }}
SECRET_TELEGRAM_API_TOKEN3: ${{ secrets.SECRET_TELEGRAM_API_TOKEN3 }}