Skip to content

Instantly share code, notes, and snippets.

@l-portet
Last active August 28, 2023 08:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save l-portet/b287b592c4c0caf9dc9307533c434eb8 to your computer and use it in GitHub Desktop.
Save l-portet/b287b592c4c0caf9dc9307533c434eb8 to your computer and use it in GitHub Desktop.
fly deploy last commit instead of all files
#!/usr/bin/env bash
last_commit=$(git log --format="%h %s" -n 1)
echo "this will deploy your last local commit"
echo $last_commit
while true; do
read -p "Do you want to continue? (y/n) " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) echo "Aborted"; exit;;
* ) echo "Please answer yes or no.";;
esac
done
tmpdir=$(mktemp -d)
echo "temporary dir created ($tmpdir)"
# duplicate & purge
echo "copying to temporary dir..."
cp -r . $tmpdir
echo "files copied"
echo "purge unstaged & untracked files"
cd $tmpdir
git stash push -u
# deploy
echo "deploying..."
if flyctl deploy --remote-only
then
echo "deployed successfully"
else
echo "deploy failed"
fi
# cleanup
cd -
rm -rf $tmpdir
echo "temporary dir removed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment