Last active
October 6, 2021 20:53
-
-
Save ArnaudLigny/0b6ec308842a487b6c942d9f388b7d38 to your computer and use it in GitHub Desktop.
A bash script to deploy a static site on 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
#!/bin/bash -e | |
USER_NAME="Build Bot" | |
USER_EMAIL="build@domain.tld" | |
REPOSITORY="username/repository" | |
TARGET_BRANCH="gh-pages" | |
SITE_DIR="_site" | |
echo "Started deploy to $REPOSITORY/$TARGET_BRANCH" | |
cp -R $SITE_DIR $HOME/$SITE_DIR | |
cd $HOME | |
git config --global user.name "$USER_NAME" | |
git config --global user.email "$USER_EMAIL" | |
git clone --quiet --branch=$TARGET_BRANCH https://${GITHUB_TOKEN}@github.com/${REPOSITORY}.git $TARGET_BRANCH > /dev/null | |
cp -R gh-pages/.git $HOME/.git | |
rm -rf gh-pages/* | |
cp -R $HOME/.git gh-pages/.git | |
cd gh-pages | |
cp -Rf $HOME/$SITE_DIR/* . | |
echo "narno.com" > CNAME | |
git add -Af . | |
git commit -m "$USER_NAME push updated website" | |
git push -fq origin $TARGET_BRANCH > /dev/null | |
echo "Finished deploy" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment