Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ lerna-debug.log*
node_modules
dist
dist-ssr
*-dist
*.local

# Editor directories and files
Expand Down
35 changes: 28 additions & 7 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,30 @@ set -e

echo "[--Build: Started--]"

# Clean up the dist directory
echo "Cleaning up the dist directory..."
rm -rf dist
# Check Deploy Type
REVISION_NAME=${1:-""} # Use the first argument or default to empty string
echo "Revision name: $REVISION_NAME"

# Set the output directory based on the deploy type
if [ "$REVISION_NAME" != "" ]; then
OUTPUT_DIR="${REVISION_NAME}-dist"
else
OUTPUT_DIR="dist"
fi
echo "Output directory: $OUTPUT_DIR"

# Clean up the output directory
echo "Cleaning up the output directory..."
rm -rf "$OUTPUT_DIR"

# Build the frontend
echo "Compiling frontend..."
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
OUTPUT_DIR="$OUTPUT_DIR" npm run build

echo "Copying extra files..."
cp /workspaces/proxy.js ./dist/proxy.js
cp ./app.package.json ./dist/package.json
cp /workspaces/proxy.js "$OUTPUT_DIR/proxy.js"
cp ./app.package.json "$OUTPUT_DIR/package.json"

echo "[--Build: Complete--]"
echo "Executing the deployment upload script"
Expand All @@ -38,15 +50,24 @@ fi

echo "Deploying as ${GITHUB_USER} to ${GITHUB_RUNTIME_PERMANENT_NAME}"

if [ "$REVISION_NAME" != "" ]; then
revision_flag="--revision-name $REVISION_NAME"
else
revision_flag=""
fi

gh runtime create \
--app ${GITHUB_RUNTIME_PERMANENT_NAME} \
--env "GITHUB_RUNTIME_PERMANENT_NAME=${GITHUB_RUNTIME_PERMANENT_NAME}" \
--secret "GITHUB_TOKEN=${GITHUB_TOKEN}" \
${revision_flag}

gh runtime deploy \
--app ${GITHUB_RUNTIME_PERMANENT_NAME} \
--dir dist
--dir "$OUTPUT_DIR" \
${revision_flag}

# TODO: Update CLI to get revision app
DEPLOYED_URL="$(gh runtime get --app ${GITHUB_RUNTIME_PERMANENT_NAME})"

echo "[--URL-App=[https://${DEPLOYED_URL}]--]"
Expand Down
3 changes: 3 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export default defineConfig({
runtimeTelemetryPlugin(),
...extraPlugins,
],
build: {
outDir: process.env.OUTPUT_DIR || 'dist'
},
define: {
// ensure that you give these types in `src/vite-end.d.ts`
GITHUB_RUNTIME_PERMANENT_NAME: JSON.stringify(GITHUB_RUNTIME_PERMANENT_NAME),
Expand Down