Last active
September 8, 2022 04:02
-
-
Save alexperronnet/5bb2f5cb866e58bef1acbd6d554ed678 to your computer and use it in GitHub Desktop.
Vite - Deploy dist folder to GitHub Pages
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
#!/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