-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·57 lines (43 loc) · 1.72 KB
/
deploy.sh
File metadata and controls
executable file
·57 lines (43 loc) · 1.72 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
#!/bin/bash
set -e
echo "[--Build: Started--]"
# Clean up the dist directory
echo "Cleaning up the dist directory..."
rm -rf dist
# Build the frontend
echo "Compiling frontend..."
# Set deploy time for build
export DEPLOY_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
echo "Setting deploy time: $DEPLOY_TIME"
npm install -f # force because there is a known mismatch of shadcn and react 19 - https://ui.shadcn.com/docs/react-19
npm run build
echo "Copying extra files..."
cp /workspaces/proxy.js ./dist/proxy.js
cp ./app.package.json ./dist/package.json
echo "[--Build: Complete--]"
echo "Executing the deployment upload script"
echo "[--Deployment: Started--]"
# Check if GITHUB_RUNTIME_PERMANENT_NAME is empty.
# This will be set when you run with the `copilot_workbench_kv_aca` flag.
if [ -z "$GITHUB_RUNTIME_PERMANENT_NAME" ]; then
echo "GITHUB_RUNTIME_PERMANENT_NAME is empty. Falling back to CODESPACE_NAME."
GITHUB_RUNTIME_PERMANENT_NAME=${CODESPACE_NAME}
size=${#GITHUB_RUNTIME_PERMANENT_NAME}
# if size is > 20, then truncate the name.
# this is a limitation that's also enforced by the dotcom API
# but I'd rather ensure that the command succeeds.
if [ $size -gt 20 ]; then
GITHUB_RUNTIME_PERMANENT_NAME=${GITHUB_RUNTIME_PERMANENT_NAME:0:20}
fi
fi
echo "Deploying as ${GITHUB_USER} to ${GITHUB_RUNTIME_PERMANENT_NAME}"
gh spark create \
--app ${GITHUB_RUNTIME_PERMANENT_NAME} \
--env "GITHUB_RUNTIME_PERMANENT_NAME=${GITHUB_RUNTIME_PERMANENT_NAME}" \
--secret "GITHUB_TOKEN=${GITHUB_TOKEN}" \
gh spark deploy \
--app ${GITHUB_RUNTIME_PERMANENT_NAME} \
--dir dist
DEPLOYED_URL="$(gh spark get --app ${GITHUB_RUNTIME_PERMANENT_NAME})"
echo "[--URL-App=[https://${DEPLOYED_URL}]--]"
echo "[--Deployment: Complete--]"