Last active
September 5, 2022 21:54
-
-
Save TooTallNate/e7a3e9b9a805add1db0bae7f1519c20e to your computer and use it in GitHub Desktop.
Uploads a single file as a Now deployment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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