Skip to content

Instantly share code, notes, and snippets.

@TooTallNate
Last active September 5, 2022 21:54
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save TooTallNate/e7a3e9b9a805add1db0bae7f1519c20e to your computer and use it in GitHub Desktop.
Uploads a single file as a Now deployment
#!/bin/bash
set -euo pipefail
input="$1"
shift
files_dir="$HOME/files"
mkdir -p "$files_dir"
# Delete old files
rm -f "$files_dir"/*
# Copy in the source file
cp "$input" "$files_dir"
cd "$files_dir"
# Create the `vercel.json` file
jq -n --arg file "$input" '{ version: 2, rewrites: [ { "source": "/", "destination": @uri "/\($file)" } ], builds: [ { src: "**/*", use: "@vercel/static" } ] }' > vercel.json
# Create deployment, copying the root `url` to clipboard instead of the aliased URL
url="$(vercel --prod --no-clipboard)"
printf "%s" "$url" | pbcopy
echo "Unique URL: $url"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment