forked from websaam/lit-cloudflare-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (64 loc) · 2.32 KB
/
deploy.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Build & Deploy to Cloudflare worker
on:
push:
branches:
- cicd
repository_dispatch:
env:
CF_EMAIL: ${{ secrets.CF_EMAIL }}
CF_GLOBAL_API: ${{ secrets.CF_GLOBAL_API }}
CF_WORKER_NAME: ${{ secrets.CF_WORKER_NAME }} # Must be lower case
CF_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
JWT_WHITE_LIST: ${{ secrets.JWT_WHITE_LIST }} # No space between commas. No https/http
jobs:
build-and-deploy:
runs-on: ubuntu-latest
name: Build & Deploy
steps:
# -- Check if environment variables are empty
- name: Check secret phases
id: checksecrets
shell: bash
run: |
if [ "$CF_EMAIL" == "" ]; then
echo ::set-output name=secretspresent::false
else
echo ::set-output name=secretspresent::true
fi
if [ "$CF_GLOBAL_API" == "" ]; then
echo ::set-output name=secretspresent::false
else
echo ::set-output name=secretspresent::true
fi
if [ "$CF_WORKER_NAME" == "" ]; then
echo ::set-output name=secretspresent::false
else
echo ::set-output name=secretspresent::true
fi
if [ "$CF_ACCOUNT_ID" == "" ]; then
echo ::set-output name=secretspresent::false
else
echo ::set-output name=secretspresent::true
fi
if [ "$JWT_WHITE_LIST" == "" ]; then
echo ::set-output name=secretspresent::false
else
echo ::set-output name=secretspresent::true
fi
# -- Rebase to root and setup to use yarn
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: "12.x"
# -- Prepare variables
- name: Prepare variables
working-directory: ./worker
run: yarn install && bash create-db.sh $CF_WORKER_NAME $CF_ACCOUNT_ID $CF_EMAIL $CF_GLOBAL_API $JWT_WHITE_LIST && cat ./wrangler.toml
# -- Build the front-end app
- name: Build App
working-directory: ./app
run: cp .env.example .env && yarn install && yarn prepare && ls && cat .env && cat vite.config.js
# -- Build the CloudFlare worker
- name: Build Worker
working-directory: ./worker
run: cat wrangler.toml && CF_EMAIL=$CF_EMAIL CF_API_KEY=$CF_GLOBAL_API yarn wrangler publish