Last active
August 28, 2023 08:59
-
-
Save l-portet/b287b592c4c0caf9dc9307533c434eb8 to your computer and use it in GitHub Desktop.
fly deploy last commit instead of all files
This file contains hidden or 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
#!/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