forked from JonathanLennox/opus-transcriber-proxy
-
Notifications
You must be signed in to change notification settings - Fork 1
119 lines (110 loc) · 4.39 KB
/
build.yaml
File metadata and controls
119 lines (110 loc) · 4.39 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: "Build and deploy"
on:
# push:
# branches:
# - master
# - main
workflow_dispatch:
inputs:
cf_env:
description: Choose environment
type: choice
required: true
options:
- dev
- staging
- prod
default: dev
branch:
description: Choose branch or tag, defaults to main
type: string
required: true
default: main
emsdk_version:
description: Emscripten SDK version, defaults to 4.0.20
type: string
required: false
default: "4.0.20"
preCommand:
description: Provide a bash script to execute before running wrangler
type: string
required: false
default: echo "No script provided for execution before running Wrangler. Moving along."
postCommand:
description: Provide a bash script to execute after running wrangler
type: string
required: false
default: echo "Nothing to execute after running Wrangler. Finishing..."
jobs:
deploy:
runs-on: "ubuntu-latest"
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ inputs.branch }}
submodules: 'true'
- name: Set environment variables
run: |
if [[ "${{ inputs.cf_env }}" == "dev" ]]; then
echo "CF_ACCOUNT=DEV_ACCOUNT_ID" >> "$GITHUB_ENV"
echo "CF_TOKEN=JITSI_CF_DEV_TOKEN" >> "$GITHUB_ENV"
elif [[ "${{ inputs.cf_env }}" == "staging" ]]; then
echo "CF_ACCOUNT=STAGE_ACCOUNT_ID" >> "$GITHUB_ENV"
echo "CF_TOKEN=JITSI_CF_STAGING_TOKEN" >> "$GITHUB_ENV"
elif [[ "${{ inputs.cf_env }}" == "prod" ]]; then
echo "CF_ACCOUNT=PROD_ACCOUNT_ID" >> "$GITHUB_ENV"
echo "CF_TOKEN=JITSI_CF_PROD_TOKEN" >> "$GITHUB_ENV"
else
echo "Invalid environment specified: ${{ inputs.cf_env }}, exiting."
exit 1
fi
- name: Install Linux deps
run: |
sudo apt update
sudo apt -y install wget unzip
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install Node Dependencies
run: |
npm ci
- name: Setup Emscripten SDK
run: |
wget https://github.com/emscripten-core/emsdk/archive/main.zip
unzip main.zip
cd emsdk-main
./emsdk install ${{ inputs.emsdk_version }}
./emsdk activate ${{ inputs.emsdk_version }}
source ./emsdk_env.sh
echo "EMSDK=$EMSDK" >> $GITHUB_ENV
echo "EM_CONFIG=$EM_CONFIG" >> $GITHUB_ENV
echo "$EMSDK:$EMSDK/upstream/emscripten" >> $GITHUB_PATH
- name: Cache emscripten build products
id: cache-emscripten
uses: actions/cache@v5
env:
cache-name: emscripten-cache
with:
path: ~/emsdk_main/upstream/emscripten/cache
key: ${{ runner.os }}-${{ env.cache-name }}-${{ inputs.emsdk_version }}
- if: ${{ steps.cache-emscripten.outputs.cache-hit }} == 'true'
name: Run emscripten sanity check after restoring cache
run: |
source "$EMSDK/emsdk_env.sh"
emcc --check
exit $?
- name: Build TS App
run: |
source "$EMSDK/emsdk_env.sh"
npm run build
- name: Wrangler Deploy
uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: "4.51.0"
apiToken: ${{ secrets[env.CF_TOKEN] }}
accountId: ${{ secrets[env.CF_ACCOUNT] }}
preCommands: ${{ inputs.preCommand }}
postCommands: ${{ inputs.postCommand }}
command: deploy