Skip to content

Instantly share code, notes, and snippets.

@alexperronnet
Last active September 8, 2022 04:02
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 alexperronnet/5bb2f5cb866e58bef1acbd6d554ed678 to your computer and use it in GitHub Desktop.
Save alexperronnet/5bb2f5cb866e58bef1acbd6d554ed678 to your computer and use it in GitHub Desktop.
Vite - Deploy dist folder to GitHub Pages
#!/usr/bin/env sh
# build
npm run build
# navigate into the build output directory
cd dist
# Initialize a git repository
git init
# Check if main branch exists
if git ls-remote --exit-code --heads origin deploy; then
git checkout main
else
git checkout -b main
fi
# Add changes to git
git add -A
# Commit changes
git commit -m 'Deploy'
# Push to deploy branch
git push -f git@github.com:${USERNAME}/${REPO}.git main:deploy
cd -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment