Awesome
deployable.site
See this project deployed at https://deployable.site
This repo simply serves as a very minimalist progressive web app boilerplate. The README however is a step-by-step guide demonstrating how to properly deploy a static web application (such as this) to GitHub pages without ever checking in built assets or directly pushing to the gh-pages
branch. This approach was pieced together from various blog posts and stackoverflow answers, making the most of free services provided by GitHub, TravisCI and CloudFlare to promote applying industry standard workflows to open source apps; review, build, test, deploy and serve over https for free with almost no configuration! Or servers for that matter :fishing_pole_and_fish:
:angel: You need a free TravisCI account and CloudFlare basic account (if you require custom https domains)
<hr/>Setup Overview
- Prepare Project: create a deployable project repository or use a fork of this repo
- Obtain Token: one per project from here, copy it and use as the value of
GITHUB_TOKEN
in travis - Enable TravisCI: switch on builds for the project here and add the
GITHUB_TOKEN
environment variable - Configure Build: add a file like this to the project root and configure for your application
- Trigger Deploy: push to master or merge a pull request to invoke a full build and deploy :boom:
1. Prepare Project
This structure of this repository adheres to a deployable configuration but that doesn't mean you have to use this code as a basis for your deployable project. This approach will work with almost any static site architecture, framework or build pipeline. The important things to recognize are:
- Deployable projects are frontend only and consists of just static files (html/css/javascript/images).
- Deployable projects build all the files they need to run into some single output directory (dist/build/public/etc).
- Deployable projects have a command that builds the project and optionally runs tests (e.g. npm run build).
- Deployable projects feature an
index.html
and a404.html
in the output directory after being built. - Deployable projects handle routing on the frontend (all server requests will return the contents of
index.html
).
If your project does not meet all the deployable requirements then you can clone/fork this repository and build upon it or tweak your project to fit.
<br/>2. Obtain Token
<hr/>- Navigate to GitHub Personal Access Token Settings
- Enter a Token Description and select the repo scope
- Scroll down and click
Generate Token
- Copy the generated access token to clipboard
3. Enable TravisCI
<hr/>- Visit your TravisCI Dashboard and find the deployable repository
- Turn on the project switch and click the settings icon
- Turn on both Auto Cancellation switches
- Under Environment Variables enter
GITHUB_TOKEN
as Name - Paste the generated access token as Value and click
Add
4. Configure Build
If you do not have a domain name for your project then use
*
.deployable.site where*
is any namespace that has not already been taken by another deployer. Choosing this option limits your site tohttp
only.
language: node_js
node_js:
- "7"
script: npm run build // The script that builds the app
deploy:
local_dir: dist // The distributed output directory
fqdn: deployable.site // The domain name of the deployed site
provider: pages
skip_cleanup: true
github_token: $GITHUB_TOKEN
on:
branch: master
<hr/>
- Clone the deployable project to your local machine
- Add a
travis.yml
file like the one above to the project root - Update
script
attribute with the command that builds your project - Update
local_dir
attribute with the name of the project output directory - Update
fqdn
attribute with the domain name the project should be deployed
5. Trigger Deploy
- Add and commit the changes to
travis.yml
thengit push
- Check the build and deploy progress on TravisCI
- When the build succeeds visit your shiny new site at the domain you specified