Skip to content

Instantly share code, notes, and snippets.

@joekarasek
Last active August 25, 2016 16:37
Show Gist options
  • Save joekarasek/d32875162412d70390a4e1aa524d3aa1 to your computer and use it in GitHub Desktop.
Save joekarasek/d32875162412d70390a4e1aa524d3aa1 to your computer and use it in GitHub Desktop.
Github pages deploy setup for ember

Setup

Add this to config/environment.js:

if (environment === 'production') {
  ENV.baseURL = '/GITHUB-REPO-NAME/dist';
  ENV.locationType = 'hash';
}

Place the .sh file in scripts/ folder.

To Use

bash scripts/deploy-to-github-pages.sh

NOTE: If you are an Epicodus student trying to figure this out, there are some bugs related to personal computer settings. Message me if you have problems.

echo "Switch to gh-pages branch"
git checkout gh-pages
git merge master
echo "Clean up"
rm -rf dist
echo "Create new production build"
ember build --environment production
echo "Add dist to commit and push it to GitHub"
git add dist --force
git commit -m "deploy"
git push
echo "Switch back to master branch"
git checkout master
<html>
<head>
<meta http-equiv="refresh" content="1;http://joekarasek.github.io/GITHUB-REPO-NAME/dist/index.html" />
</head>
<body>
</body>
</html>
@pokojt
Copy link

pokojt commented Apr 11, 2016

Step-by-Step Directions

  1. Within your project, include the if statement code ("Setup", above) in your config/environment.js file, adding your unique github repo name.
  2. In the top level of your project, create an empty index.html file and include the code and link provided above (index.html), adding your own GitHub URL and repo name.
  3. In the console, move into your project folder and commit the changes.
  4. Create a gh-pages branch by running $git checkout -b gh-pages.
  5. Move into your gh-pages branch and run $ember build --environment production (must have npm and bower installed first). This builds your project for production and creates a dist folder in your project.
  6. Run $git add --force dist. This forces git to commit the dist folder, even though it is in your .gitignore file.
  7. Commit.
  8. $git push (remote-repo-name) gh-pages
  9. View the project at your-github-URL.github.io/your-repo-name

@patternandshape
Copy link

you guys are the best! thank you :)

@joekarasek
Copy link
Author

Taylor, thanks for the step-by-step!

@Jordan-Meier
Copy link

This is so helpful! Thanks, guys!

@mknutgit
Copy link

mknutgit commented Aug 25, 2016

This was a life saver, thanks so much!

Wanted to add a couple more steps for when you make updates to the site and need to refresh the gh-pages. May be obvious, but wanted to document it.

  1. $git checkout gh-pages
  2. $git merge master
  3. $ember build --environment production
  4. $git add --force dist
  5. $ commit.
    6 $git push (remote-repo-name) gh-pages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment